System Calls: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
mNo edit summary
Fixes of grammar and speech mistakes
Line 1:
System Calls are used to call a kernel service from user land. The goal is to be able to switch from user mode to kernel mode, with the associated privileges. Provided system calls dependsdepend on the nature of your [[Kernels|kernel]].
 
==Possible methods to make a System Call ==
Line 14:
IRETD
</source>
Which will give you problems when you want to return values to the user. One method to fix this is by writing ana handler that simply calls another function, so that registers are not preserved.
<source lang="asm">
IntHandler:
Line 21:
</source>
 
Many protected mode OSes use EAX to hold the function code. DOS uses the AX register to store the function code - AH for the service and AL for functions of the service, or AH for the functions if there are no services. For example, let's say you have read() and write(). The codes are 1 for read() and 2 for write() from the interrupt 0A9h (an arbitrary choice, possibly wrong). You can write
<source lang="asm">
IntA9Handler:
Line 88:
 
==On the user land side==
While the developper can trigger thea system call manually, it is probably a good idea to provide a library to encapsulate such a call. Therefore you wilwill be able to switch the system call technique without impacting the user applications.
 
Another way is to have a stub somewhere in memory that the kernel places there, then once your registers are set up, call that stub to do the actual system call for you. Then you can swap methods at load time rather than compile time.
 
==Strategies Conlusion==
The system call strategy depends on the platform. You may want to use different strategy depending on the architecture, and even switch strategy depending on the hardware performance. You might also need more parameter copying on a [[Microkernel|microkernel]] than you will need on a [[Monolithic_Kernel|monolithic]] one.
 
==See Also==