You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Processes I<br />
! System Call Interface<br />
algorithm syscall<br />
/* algorithm for invocation of system call */<br />
input: system call number<br />
output: result of system call<br />
{<br />
find entry in system call table corresponding to system<br />
call number;<br />
determine number of parameters to system call;<br />
copy parameters from user address space to u area;<br />
save current context for abortive return;<br />
invoke system call code in kernel;<br />
if (error during execution of system call)<br />
{<br />
set register 0 in user saved register context to<br />
error number;<br />
turn on carry bit in PS register in user saved<br />
register context;<br />
}<br />
else<br />
set registers 0, 1 in user saved register context<br />
to return values from system call;<br />
}<br />
Figure 14. Example of Interrupts<br />
Figure 15. Algorithm for System Calls Invocations<br />
! Context Switch<br />
Figure 16. Stack configuration for creat system call<br />
1. Decide whe<strong>the</strong>r to do a context switch, and<br />
whe<strong>the</strong>r a context switch is permissible now.<br />
2. Save <strong>the</strong> context of <strong>the</strong> "old" process.<br />
3. Find <strong>the</strong> "best" process to schedule for execution,<br />
using process scheduling algorithm of Figure 46.<br />
4. Restore its context.<br />
Figure 17. Steps for a Context Switch<br />
103<br />
if (save context()) /* save context of executing process * /<br />
{<br />
/* pick ano<strong>the</strong>r process to run */<br />
…<br />
resume_context (new...process); /* never gets here! */<br />
}<br />
/* resuming process executes from here */<br />
Figure 18. Pseudo-Code for Context Switch