views:

141

answers:

4

For example, a process waiting for disk I/O to complete will sleep on the address of the buffer header corresponding to the data being transferred. When the interrupt routine for the disk driver notes that the transfer is complete, it calls wakeup on the buffer header. The interrupt uses the kernel stack for whatever process happened to be running at the time, and the wakeup is done from that system process.

Can you please explain the last line in the paragraph which I have emphasised. It is about waking up the process which has been waiting for some event to occur and thus has slept. This para is from Galvin. By the way can you suggest some good book or link for studying unix operating systems?

Thanks.

+1  A: 

There is some process running at the time the interrupt is received. The kernel doesn't change over to some other process context to handle it -- that would take time -- it just does what's necessary in the current context, and lets the scheduler know that the next time it schedules, the waiting process is ready to proceed.

There are a number of good internals books around. I'm fond of the various McKusick et al books, like The Design and Implementation of the FreeBSD Operating System.

Charlie Martin
really thanks for that.can u plz also explain this;FreeBSD implements page coloring withpaging queues. The queues are arranged according to the size of the processor’s L1 and L2 caches; and when a new page needs to be allocated, FreeBSD tries to get one that is optimally aligned for the cache.thanks
mawia
Wow, not in a comment I can't.
Charlie Martin
A: 

The I/O completion interrupt will be executed as soon as the disk signals the end of the transfer. This is done regardless of what the kernel is currently doing. Interrupt handlers are usually very small and self-contained. Therefore it is faster to re-use the current runtime environment (stack, CPU state, etc) instead of doing a full context switch to a separate thread. On the down side this means that interrupt handlers are only allowed to do very limited things, like setting a flag somewhere else, or enqueing a work item. Also, they have to clean up very carefully after themselves, so that the running process is not disturbed.

David Schmitt
+1  A: 

Maurice Bach's Design of the Unix Operating System is the most well-known and comprehensive book on the subject.

Frederick
Another good one.
Charlie Martin
A: 

Eric Raymond's 'The Art of Unix Programming' , should be read to understand the Unix philosophy and culture.To actually know and appreciate the reasons behind its design.

Prabhu. S