16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Processes I<br />

The Context of a Process<br />

The register context consists of:<br />

- program counter processor status<br />

- register stack pointer<br />

- general purpose registers<br />

The system-level context consists of:<br />

- process table entry<br />

- <strong>the</strong> u area<br />

- pregion entries<br />

- kernel stack<br />

- dynamic part - set of layer<br />

Figure 11. Components of Context of a Process<br />

Saving <strong>the</strong> Context of a Process<br />

! Interrupts and Exceptions<br />

Kernel sequence to handle interrupts:<br />

1. save current register context, push a new context layer<br />

2. determine source of interrupt, type of interrupt, interrupt number<br />

Figure 12. Sample Interrupt Vector<br />

Interrupt Interrupt<br />

Number Handler<br />

0 c1ockintr<br />

1 diskintr<br />

2 ttyintr<br />

3 devintr<br />

4 softintr<br />

5 o<strong>the</strong>rintr<br />

3. invoke interrupt handler<br />

4. restore register context and kernel stack of previous context layer<br />

algorithm inthand /* handle interrupts */<br />

input: none<br />

output: none<br />

{<br />

save (push) current context layer; determine interrupt source;<br />

find interrupt vector;<br />

call interrupt handler;<br />

restore (pop) previous context layer;<br />

}<br />

Figure 13. Handling Interrupts<br />

102

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!