You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Introduction to kernel<br />
...<br />
C runtime library<br />
open(char *name, int mode)<br />
{<br />
place parameters in registers.<br />
execute trap instruction, switching to kernel code<br />
return result of system call<br />
}<br />
Kernel<br />
system call vector table<br />
...<br />
address of kernel close()<br />
address of kernel open()<br />
address of kernel write()<br />
...<br />
-----------------------------------<br />
kernel system call code<br />
kernel code for open()<br />
{<br />
manipulate kernel data structures<br />
...<br />
return to user code and user mode<br />
}<br />
The scheduler will not assign <strong>the</strong> CPU to ano<strong>the</strong>r process during <strong>the</strong> execution of a system call. i.e. when a process<br />
performs a system call, it cannot be "preempted".<br />
System calls that make I/O requests from a device, may take time to complete. To avoid leaving <strong>the</strong> CPU idle, <strong>the</strong><br />
kernel puts <strong>the</strong> process to sleep and wakes it <strong>with</strong> a hardware interrupt signalling I/O completion.<br />
Interrupts<br />
highest<br />
priority<br />
0<br />
1<br />
2<br />
3<br />
4<br />
Interrupt vector table<br />
hardware errors<br />
clock<br />
disk I/O<br />
keyboard<br />
traps S/W interrupts<br />
pointers to kernel<br />
interrupt handlers<br />
lowest<br />
priority<br />
current process suspend resume<br />
----------------------------> - - - - - - - - - - - - - - - -------------------------------><br />
| |<br />
| keyboard interrupt handler |<br />
|----------------------------------------------->|<br />
keyboard interrupt<br />
completed<br />
When an interrupt occurs, <strong>the</strong> current process is suspended and <strong>the</strong> kernel determines <strong>the</strong> source of <strong>the</strong> interrupt. It<br />
<strong>the</strong>n examines <strong>the</strong> interrupt vector table to find <strong>the</strong> location of <strong>the</strong> code to process <strong>the</strong> interrupt.<br />
If a higher priority interrupt than <strong>the</strong> current arrives, <strong>the</strong> lower priority interrupt handler is suspended until <strong>the</strong><br />
higher priority interrupt completes.<br />
Critical sections of kernel code protect <strong>the</strong>mselves from interrupts by temporarily disabling interrupts.<br />
<br />
<br />
…<br />
<br />
<br />
89