Published on

its a simple presentation for system call

Published in: Education, Technology, Sports
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. Algorithm of<br />syscall<br />Mahesh Shitole<br />Associate Software Engineer<br />Knowledge Quest Infotech<br />
  2. 2. <ul><li> All the system calls are declared in C library. so when process makes system call linker links function call to name of it in this Library.
  3. 3. The Library Doesn’t have code , it just have
  4. 4. Name of the function
  5. 5. Trap instruction </li></ul>Code reside in kernel.<br /><ul><li>when system call made it invoke Trap instruction it generate interrupt and h/w switch to the kernel mode.
  6. 6. After creating OS Trap library pass a unique no. to kernel.
  7. 7. it can pass this either using
  8. 8. As a parameter to instruction itself
  9. 9. On the stack</li></ul> depending upon machine. <br />
  10. 10. <ul><li>Now we enter in kernel mode.
  11. 11. There is a table of System calls. In which kernel finds appropriate</li></ul> require function address using index. This address are nothing but entry point of system call.<br /><ul><li>parameters :
  12. 12. we know process has 2 stacks kernel stack & user stack in the frame of user stack there are parameters of called function , so using user stack pointer it adds or subtracts an offset & get the parameters of system call.
  13. 13. it copies this parameters to the Process’s U area & start executing the code of system call. </li></li></ul><li><ul><li> After Executing System call </li></ul> two situation are <br /><ul><li>Success with or without return value: </li></ul> process state register (PS) field carry bit is set which is used in error situation. Here there is no error so kernel clear this bit.<br /> and copies return values into 0th & 1st register of <br />register level context . (Data register)<br /><ul><li>Error with return value:</li></ul> when the kernel determine the execution of system call completed with some error , it sets the carry bit in process status register (PS). & copies the error no into the 0th register <br /> of register context.<br /><ul><li>Here the job of system call i.e. OS Trap is done. Kernel returns to</li></ul> to the library where Trap was created.<br /> library checks the status of PS register & take appropriate action.<br /> usually they return it to caller process & process takes action. <br />
  14. 14. algorithm : syscall /* from invocation of system call * <br />input : system call number (takes from “trap”)<br />{<br />find entry in “system call table” corresponding to system call number;<br />determine number of parameters to the system call;<br />copy parameters from “user address space” to U area;<br />save current context for abortive return;<br />invoke the code of system call reside in kernel;<br />if(error during execution of system call)<br />{<br /> set register 0 in “register context” to the error number;<br /> turn on “carry bit” in “process status” register in register context;<br />}<br />else /* success */<br /> set register 0 and 1 in “register context” to return values of system call; <br />}<br />output : result of system call. <br />