<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5313249829740971301</id><updated>2011-12-31T18:23:43.693+05:30</updated><title type='text'>Interesting Stuff</title><subtitle type='html'>At least, interesting to me!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-8774201330194934757</id><published>2011-12-31T18:22:00.003+05:30</published><updated>2011-12-31T18:23:43.704+05:30</updated><title type='text'>Will be back</title><content type='html'>I know I have been silent for more than a year now! Will be back with more in 2012.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-8774201330194934757?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/8774201330194934757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2011/12/will-be-back.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8774201330194934757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8774201330194934757'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2011/12/will-be-back.html' title='Will be back'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-2713317857488145672</id><published>2010-11-12T09:55:00.007+05:30</published><updated>2010-11-14T20:20:52.105+05:30</updated><title type='text'>kernel/proc.c - sys_call() internals</title><content type='html'>I gave some idea about &lt;span style="font-family:courier new;"&gt;sys_call()&lt;/span&gt; in the preceding diagrams. &lt;span style="font-family:courier new;"&gt;sys_call()&lt;/span&gt; does a number of checks before it allows a message or notification to be passed from one process to another. These are all part of the security mechanisms in the kernel that keep processes from doing things they are not allowed to do and from corrupting each other's memory maps. Assuming that a process has just made a system call, here is the list of checks that happen:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Does the process have the privileges to make this particular system call? (the &lt;a href="http://vishy-ranganath.blogspot.com/2009/12/minix-process-table.html"&gt;&lt;span style="font-family:courier new;"&gt;priv&lt;/span&gt;&lt;/a&gt; structure for this process in the process table is looked up to determine this)&lt;/li&gt;&lt;li&gt;In the case of a 'send' or 'notify', is the destination a valid process? In the case of a 'receive' is the source a valid process? Note that a caller can specify 'ANY' as its source in which case it is looking for a message or notification from any process, so this check is unnecessary for that case. 'ECHO' is also a special case where this check doesn't make sense.&lt;/li&gt;&lt;li&gt;Does the message pointer point to a valid region in memory i.e. is it really within the memory map limits of the calling process? Again, the memory map limits are available in the &lt;a href="http://vishy-ranganath.blogspot.com/2009/12/minix-process-table.html"&gt;&lt;span style="font-family:courier new;"&gt;memmap&lt;/span&gt;&lt;/a&gt; struct for this process in the process table.&lt;/li&gt;&lt;li&gt;If the request is to 'send' to some process, is the caller allowed to send to the destination process?&lt;/li&gt;&lt;li&gt;Is the destination process running?&lt;/li&gt;&lt;li&gt;Has system shutdown started?&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;If all the checks above have passed then call one of the following functions: &lt;span style="font-family:courier new;"&gt;mini_notify()&lt;/span&gt;, &lt;span style="font-family:courier new;"&gt;mini_receive()&lt;/span&gt; or &lt;span style="font-family:courier new;"&gt;mini_send()&lt;/span&gt; depending upon the nature of the request.&lt;br /&gt;&lt;br /&gt;Refer to the 'Message Primitives and Process States' diagrams (preceding posts) for details on what happens within the above functions.&lt;br /&gt;&lt;br /&gt;Comments welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-2713317857488145672?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/2713317857488145672/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/kernelprocc-syscall-internals.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2713317857488145672'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2713317857488145672'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/kernelprocc-syscall-internals.html' title='kernel/proc.c - sys_call() internals'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-4317817302127360531</id><published>2010-11-08T17:58:00.002+05:30</published><updated>2010-11-08T17:59:22.705+05:30</updated><title type='text'>Message Primitives and Process States - Case 3</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7sXqWG_R86A/TNftF12YSgI/AAAAAAAAHIo/des24FuTZbw/s1600/Message+Primitives+and+Process+States+-+Case+3.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 200px;" src="http://1.bp.blogspot.com/_7sXqWG_R86A/TNftF12YSgI/AAAAAAAAHIo/des24FuTZbw/s320/Message+Primitives+and+Process+States+-+Case+3.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5537154951485606402" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-4317817302127360531?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/4317817302127360531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/message-primitives-and-process-states_08.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4317817302127360531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4317817302127360531'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/message-primitives-and-process-states_08.html' title='Message Primitives and Process States - Case 3'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_7sXqWG_R86A/TNftF12YSgI/AAAAAAAAHIo/des24FuTZbw/s72-c/Message+Primitives+and+Process+States+-+Case+3.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-2226774226164637292</id><published>2010-11-03T21:47:00.000+05:30</published><updated>2010-11-03T21:48:29.801+05:30</updated><title type='text'>Message Primitives and Process States - Case 2</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7sXqWG_R86A/TNGLTrllawI/AAAAAAAAHIU/-vIYcpDbayM/s1600/Message+Primitives+and+Process+States+-+Case+2.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 200px;" src="http://3.bp.blogspot.com/_7sXqWG_R86A/TNGLTrllawI/AAAAAAAAHIU/-vIYcpDbayM/s320/Message+Primitives+and+Process+States+-+Case+2.jpg" alt="" id="BLOGGER_PHOTO_ID_5535358587249191682" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-2226774226164637292?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/2226774226164637292/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/message-primitives-and-process-states_03.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2226774226164637292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2226774226164637292'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/message-primitives-and-process-states_03.html' title='Message Primitives and Process States - Case 2'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7sXqWG_R86A/TNGLTrllawI/AAAAAAAAHIU/-vIYcpDbayM/s72-c/Message+Primitives+and+Process+States+-+Case+2.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-7778103705314929645</id><published>2010-11-03T19:27:00.002+05:30</published><updated>2010-11-03T21:47:28.367+05:30</updated><title type='text'>Message Primitives and Process States - Case 1</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7sXqWG_R86A/TNGLDzfuhoI/AAAAAAAAHIM/H2rV0WVgiCk/s1600/Message+Primitives+and+Process+States+-+Case+1.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 200px;" src="http://1.bp.blogspot.com/_7sXqWG_R86A/TNGLDzfuhoI/AAAAAAAAHIM/H2rV0WVgiCk/s320/Message+Primitives+and+Process+States+-+Case+1.jpg" alt="" id="BLOGGER_PHOTO_ID_5535358314494199426" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7sXqWG_R86A/TNFqhjIZ2sI/AAAAAAAAHIE/tg10uXJw-NM/s1600/Message+Primitives+and+Process+States+-+Case+1.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-7778103705314929645?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/7778103705314929645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/message-primitives-and-process-states.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/7778103705314929645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/7778103705314929645'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/message-primitives-and-process-states.html' title='Message Primitives and Process States - Case 1'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_7sXqWG_R86A/TNGLDzfuhoI/AAAAAAAAHIM/H2rV0WVgiCk/s72-c/Message+Primitives+and+Process+States+-+Case+1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-4511939519743469953</id><published>2010-11-01T12:44:00.011+05:30</published><updated>2010-11-01T21:37:36.771+05:30</updated><title type='text'>Process scheduling in Minix</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7sXqWG_R86A/TM6VNsMPlCI/AAAAAAAAHF0/Wi6mOCjzj-o/s1600/Minix+Process+State+Transitions.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 200px;" src="http://2.bp.blogspot.com/_7sXqWG_R86A/TM6VNsMPlCI/AAAAAAAAHF0/Wi6mOCjzj-o/s320/Minix+Process+State+Transitions.jpg" alt="" id="BLOGGER_PHOTO_ID_5534525054518268962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The diagram above shows the state transitions for any process in Minix. A &lt;span style="font-style: italic;"&gt;running&lt;/span&gt; process can become &lt;span style="font-style: italic;"&gt;blocked&lt;/span&gt; when it makes a system call (which translates into the INT assembly instruction, also known as a software interrupt). Once blocked, it has to become &lt;span style="font-style: italic;"&gt;ready&lt;/span&gt; before it can be run again. The scheduling algorithm only picks ready processes for execution.&lt;br /&gt;&lt;br /&gt;The kernel maintains 16 queues of runnable processes. These queues are numbered 0 (highest priority queue) to 15 (lowest priority queue). Different processes have different priorities and the priority of a process may change during its execution. The changed priority is reflected in the fact that the process is moved to a different scheduling queue.&lt;br /&gt;&lt;br /&gt;The clock and system tasks in Layer 1 of Minix have the highest priority. The device drivers in Layer 2 get lower priority but they are all not equal. Server processes (process manager, file system etc.) get lower priority than device drivers. User processes get lower priority than the server processes. Refer to &lt;a href="http://3.bp.blogspot.com/_7sXqWG_R86A/TKBRrAdAHKI/AAAAAAAAG9o/oqDNaOKPUwo/s1600/Minix+Startup+Sequence+Part+2.jpg"&gt;this post&lt;/a&gt; for more on these layers.&lt;br /&gt;&lt;br /&gt;Scheduling is round robin in each queue. If a running process uses up its quantum, it is moved to the tail of its queue and given a new quantum (Transition 4 in the diagram above). When a blocked process is awakened it is put at the head of its queue if it had any part of its quantum left when it blocked (Transition 2 in the diagram above). But it does not get a new quantum. It gets only as much quantum as it was left with when it blocked.&lt;br /&gt;&lt;br /&gt;Whenever a running process becomes blocked or a runnable or running process is killed by a signal, it is removed from the scheduling queues. &lt;span style="font-style: italic;"&gt;What this means is that the scheduling queues contain only ready or runnable processes.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Given this structure, the rule is very simple: Find the highest priority queue that is not empty and pick and continue running the process that is at the head of that queue.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;So here is the chain of events at a high level: &lt;i&gt;Process A is running -&gt; Hardware and software interrupts occur -&gt; interrupt handling code runs -&gt; messages or notifications are sent or received -&gt; the message processing results in process state transitions which causes changes to the scheduling queues in the kernel -&gt; so Process B gets selected for execution.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;We have discussed in detail how context switching happens and how the scheduling logic works. It is clear that the state transitions in the above diagram really drive the context switching. But what really causes these state transitions? The answer lies in the messaging layer of Minix. That is the final missing piece of the puzzle and I will discuss it with another diagram in an upcoming post.&lt;br /&gt;&lt;br /&gt;Comments welcome.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-4511939519743469953?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/4511939519743469953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/process-scheduling-in-minix.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4511939519743469953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4511939519743469953'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/11/process-scheduling-in-minix.html' title='Process scheduling in Minix'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7sXqWG_R86A/TM6VNsMPlCI/AAAAAAAAHF0/Wi6mOCjzj-o/s72-c/Minix+Process+State+Transitions.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-5125044078380948465</id><published>2010-10-23T21:21:00.015+05:30</published><updated>2010-10-25T10:57:38.717+05:30</updated><title type='text'>Minix Context Switching Detail</title><content type='html'>Download and view this &lt;a href="https://sites.google.com/site/vishyranganath/home/announcements/firstpost/MinixContextSwitching.pdf?attredirects=0&amp;amp;d=1"&gt;PDF&lt;/a&gt; file.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_7sXqWG_R86A/TMMWUnKMgkI/AAAAAAAAHAo/Sv51JkqVcJk/s1600/Minix+Context+Switching.jpg"&gt;&lt;br /&gt;&lt;/a&gt;I have shown both hardware and software interrupt workflows here. Since the diagram is large and complex, it may have some errors due to oversight. Comments/corrections welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-5125044078380948465?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/5125044078380948465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/minix-context-switching-detail.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/5125044078380948465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/5125044078380948465'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/minix-context-switching-detail.html' title='Minix Context Switching Detail'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-8292667054251480825</id><published>2010-10-20T22:39:00.001+05:30</published><updated>2010-10-20T22:40:38.682+05:30</updated><title type='text'>Context Switching</title><content type='html'>I think I now understand &lt;span style="font-style: italic;"&gt;exactly&lt;/span&gt; how context switching happens in Minix. I am working on a detailed diagram which I will upload once I am done.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-8292667054251480825?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/8292667054251480825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/context-switching.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8292667054251480825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8292667054251480825'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/context-switching.html' title='Context Switching'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-5481034637976217389</id><published>2010-10-17T21:30:00.003+05:30</published><updated>2010-10-23T23:12:44.801+05:30</updated><title type='text'>Minix Interrupt Handling</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7sXqWG_R86A/TMMeeH5dBwI/AAAAAAAAHA4/nPoYPUXNVnU/s1600/Minix+Interrupt+Handling.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 200px;" src="http://3.bp.blogspot.com/_7sXqWG_R86A/TMMeeH5dBwI/AAAAAAAAHA4/nPoYPUXNVnU/s320/Minix+Interrupt+Handling.jpg" alt="" id="BLOGGER_PHOTO_ID_5531298270206035714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7sXqWG_R86A/TLse6YNTO-I/AAAAAAAAG_U/akCFSfFLotI/s1600/Minix+Interrupt+Handling.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-5481034637976217389?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/5481034637976217389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/minix-interrupt-handling.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/5481034637976217389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/5481034637976217389'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/minix-interrupt-handling.html' title='Minix Interrupt Handling'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7sXqWG_R86A/TMMeeH5dBwI/AAAAAAAAHA4/nPoYPUXNVnU/s72-c/Minix+Interrupt+Handling.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-2796166244187315340</id><published>2010-10-17T21:14:00.005+05:30</published><updated>2010-10-17T21:30:02.637+05:30</updated><title type='text'>Context Switching - The illusion of multiple processes executing simultaneously</title><content type='html'>In a single processor system, at any instant, &lt;i&gt;only one&lt;/i&gt; process is executing - be it a system process (part of the OS) or a user process. The illusion of multiple processes running simultaneously is achieved by constantly switching from process to process. Now, when does a context switch happen in minix? What causes the CPU to suspend execution of one process and resume another? There are three ways in which this can happen:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. Hardware interrupt (one of the devices in the computer sends a signal to the interrupt controller which in turn sends an interrupt signal to the INT pin of the CPU)&lt;/div&gt;&lt;div&gt;2. Software interrupt (i. e. system call made by the executing process)&lt;/div&gt;&lt;div&gt;3. The 'quantum' of time assigned to the executing process has been used up, so this process is pre-emptively suspended and another one is picked for execution. (This is really a special case of hardware interrupt where the interrupting device is the clock.)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In upcoming posts, I will first explain interrupt processing and context switching and then give more details on scheduling of processes.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-2796166244187315340?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/2796166244187315340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/context-switching-illusion-of-multiple.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2796166244187315340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2796166244187315340'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/context-switching-illusion-of-multiple.html' title='Context Switching - The illusion of multiple processes executing simultaneously'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-8617203063528102357</id><published>2010-10-15T07:58:00.015+05:30</published><updated>2010-10-15T10:16:38.875+05:30</updated><title type='text'>The Global Descriptor Table</title><content type='html'>The GDT (Global Descriptor Table), LDTs (Local Descriptor Tables) and the IDT (Interrupt Descriptor Table) , all located in memory provide protected access to system resources. The GDT and IDT are pointed to by special registers within the CPU (so the processor can access them), and the GDT entries point both to the operating system segments and to the LDTs. The IDT contains pointers to code that needs to be executed when interrupts occur.&lt;br /&gt;&lt;br /&gt;Each running program has its own LDT but there is a &lt;span style="FONT-STYLE: italic"&gt;single GDT &lt;/span&gt;for the entire system.&lt;br /&gt;&lt;br /&gt;The LDT describes segments local to each program including its text (code), data, stack and so on. The GDT describes system segments including the operating system itself. (Segments are independent address spaces. Segmentation is one of the techniques use to manage memory on computers. More on segments when we discuss memory management but for now just understand that with segmented memory, we need a two part address to reach any memory location - the first part is the address of the segment and the second part is the location (offset) within the segment.)&lt;br /&gt;&lt;br /&gt;So the GDT basically points to (i.e. contains the physical addresses of) segments that contain the operating system code and data but also provides a way to get to all the LDTs in the system.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-8617203063528102357?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/8617203063528102357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/global-descriptor-table-gdt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8617203063528102357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8617203063528102357'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/global-descriptor-table-gdt.html' title='The Global Descriptor Table'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-8496142216193209578</id><published>2010-10-03T14:00:00.006+05:30</published><updated>2010-10-23T23:06:19.110+05:30</updated><title type='text'>Intel 386 Processor Registers (32 bit)</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7sXqWG_R86A/TMMdCrv6dfI/AAAAAAAAHAw/Uf-oLGYp-10/s1600/Intel+386+Processor+Registers.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 249px;" src="http://2.bp.blogspot.com/_7sXqWG_R86A/TMMdCrv6dfI/AAAAAAAAHAw/Uf-oLGYp-10/s400/Intel+386+Processor+Registers.jpg" alt="" id="BLOGGER_PHOTO_ID_5531296699281733106" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7sXqWG_R86A/TL8iNzhagMI/AAAAAAAAG_w/PR-S3op1HNs/s1600/Intel+386+Processor+Registers.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_7sXqWG_R86A/TLfOeZD5VjI/AAAAAAAAG-s/a0PBbZR3jkw/s1600/Intel+386+Processor+Registers.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7sXqWG_R86A/TKhD2krJ50I/AAAAAAAAG-Q/JSu_3ivPb3U/s1600/Intel+386+Processor+Registers.jpg"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-8496142216193209578?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/8496142216193209578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/intel-386-processor-registers-32-bit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8496142216193209578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8496142216193209578'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/intel-386-processor-registers-32-bit.html' title='Intel 386 Processor Registers (32 bit)'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7sXqWG_R86A/TMMdCrv6dfI/AAAAAAAAHAw/Uf-oLGYp-10/s72-c/Intel+386+Processor+Registers.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-8284979865286108961</id><published>2010-10-02T17:02:00.002+05:30</published><updated>2010-10-02T17:12:29.834+05:30</updated><title type='text'>The Minix Startup Sequence Call Flow</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7sXqWG_R86A/TKcamY06haI/AAAAAAAAG-I/KRfuPM_ZIAs/s1600/Minix+Startup+Sequence+Call+Flow.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 200px;" src="http://1.bp.blogspot.com/_7sXqWG_R86A/TKcamY06haI/AAAAAAAAG-I/KRfuPM_ZIAs/s320/Minix+Startup+Sequence+Call+Flow.jpg" alt="" id="BLOGGER_PHOTO_ID_5523412714794943906" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7sXqWG_R86A/TKcYeeOOz1I/AAAAAAAAG-A/oI1-HTAfuKk/s1600/Minix+Startup+Sequence+Call+Flow.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-8284979865286108961?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/8284979865286108961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/minix-startup-sequence-call-flow.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8284979865286108961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8284979865286108961'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/10/minix-startup-sequence-call-flow.html' title='The Minix Startup Sequence Call Flow'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_7sXqWG_R86A/TKcamY06haI/AAAAAAAAG-I/KRfuPM_ZIAs/s72-c/Minix+Startup+Sequence+Call+Flow.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-3709495902956376884</id><published>2010-09-29T06:54:00.006+05:30</published><updated>2010-09-29T07:09:39.525+05:30</updated><title type='text'>Privilege Levels</title><content type='html'>The architecture of 32-bit Intel processors provides four privilege levels of which Minix takes advantage of three. These are defined as C macros in kernel/protect.h&lt;br /&gt;&lt;br /&gt;#define INTR_PRIVILEGE 0 /* kernel and interrupt handlers */&lt;br /&gt;#define TASK_PRIVILEGE 1 /* kernel tasks */&lt;br /&gt;#define USER_PRIVILEGE 3 /* servers and user processes */&lt;br /&gt;&lt;br /&gt;The kernel contains code that runs during interrupts and during context switches, so it always runs with INTR_PRIVILEGE. &lt;span style="font-style: italic;"&gt;Every address in memory and every register in the CPU can be accessed by a process with this privilege level.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The System and Clock tasks run with the TASK_PRIVILEGE level which allows them to access I/O but not to use instructions that modify special registers (like those that point to descriptor tables).&lt;br /&gt;&lt;br /&gt;Servers and user processes run at USER_PRIVILEGE level. Such processes are unable to execute certain instructions such as those that access I/O ports, change memory assignments or change privilege levels themselves.&lt;br /&gt;&lt;br /&gt;Note that of the four layers of processes in the Minix OS, all the layers except Layer 1 run with USER_PRIVILEGE level (i.e. user mode).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-3709495902956376884?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/3709495902956376884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/09/privilege-levels.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/3709495902956376884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/3709495902956376884'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/09/privilege-levels.html' title='Privilege Levels'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-3629679970441138560</id><published>2010-09-28T09:26:00.002+05:30</published><updated>2010-09-28T09:32:45.304+05:30</updated><title type='text'>Fork</title><content type='html'>Just for the heck of it, I added some print statements to the code in forkexit.c in the Minix source. After recompiling, linking, creating a boot image and installing in the boot directory when I restarted the machine, all I could see was thousands and thousands of those messages I had introduced. After startup, no matter what I did the screen was littered with those messages. Which is natural since fork happens (one or more times) whenever you execute a command.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-3629679970441138560?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/3629679970441138560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/09/fork.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/3629679970441138560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/3629679970441138560'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/09/fork.html' title='Fork'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-4555056773283046695</id><published>2010-09-27T13:40:00.001+05:30</published><updated>2010-09-27T13:41:35.032+05:30</updated><title type='text'>The Minix Startup Sequence Part 2</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7sXqWG_R86A/TKBRrAdAHKI/AAAAAAAAG9o/oqDNaOKPUwo/s1600/Minix+Startup+Sequence+Part+2.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 200px;" src="http://3.bp.blogspot.com/_7sXqWG_R86A/TKBRrAdAHKI/AAAAAAAAG9o/oqDNaOKPUwo/s320/Minix+Startup+Sequence+Part+2.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5521502942454095010" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-4555056773283046695?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/4555056773283046695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/09/minix-startup-sequence-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4555056773283046695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4555056773283046695'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/09/minix-startup-sequence-part-2.html' title='The Minix Startup Sequence Part 2'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7sXqWG_R86A/TKBRrAdAHKI/AAAAAAAAG9o/oqDNaOKPUwo/s72-c/Minix+Startup+Sequence+Part+2.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-1687951125895713396</id><published>2010-09-27T11:51:00.004+05:30</published><updated>2010-10-01T12:00:27.746+05:30</updated><title type='text'>The Minix Startup Sequence Part 1</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7sXqWG_R86A/TKV_9wFvHjI/AAAAAAAAG94/r9kZzIGLZGo/s1600/Minix+Startup+Sequence+Part+1.jpg"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 200px;" src="http://2.bp.blogspot.com/_7sXqWG_R86A/TKV_9wFvHjI/AAAAAAAAG94/r9kZzIGLZGo/s320/Minix+Startup+Sequence+Part+1.jpg" alt="" id="BLOGGER_PHOTO_ID_5522961216897490482" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7sXqWG_R86A/TKSKiBVq5DI/AAAAAAAAG9w/Bx10Pwe5d-U/s1600/Minix+Startup+Sequence+Part+1.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_7sXqWG_R86A/TKA4ZOI5zMI/AAAAAAAAG9g/Whv88CPE8T4/s1600/Minix+Startup+Sequence+Part+1.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-1687951125895713396?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/1687951125895713396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/09/minix-startup-sequence-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/1687951125895713396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/1687951125895713396'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/09/minix-startup-sequence-part-1.html' title='The Minix Startup Sequence Part 1'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7sXqWG_R86A/TKV_9wFvHjI/AAAAAAAAG94/r9kZzIGLZGo/s72-c/Minix+Startup+Sequence+Part+1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-3133408762689886127</id><published>2010-07-06T09:19:00.002+05:30</published><updated>2010-07-06T09:22:35.553+05:30</updated><title type='text'>The Banker's Algorithm for avoiding deadlocks</title><content type='html'>The Banker's Algorithm for avoiding deadlocks is about as effective as banker's hours are in the software development industry. Read it for academic interest.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-3133408762689886127?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/3133408762689886127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/07/bankers-algorithm-for-avoiding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/3133408762689886127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/3133408762689886127'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/07/bankers-algorithm-for-avoiding.html' title='The Banker&apos;s Algorithm for avoiding deadlocks'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-2226702123174680263</id><published>2010-07-01T06:48:00.004+05:30</published><updated>2010-07-01T07:02:10.054+05:30</updated><title type='text'>Deadlocks</title><content type='html'>I am back after quite a while. Time-slicing works well for processors but not for the human brain. It is better to do a few things well by spending enough time on each of them than to do a hundred things without making much progress in any.&lt;br /&gt;&lt;br /&gt;Anyway, I am studying deadlocks right now. The formal definition (unlike most formal definitions!) is quite easy to comprehend: &lt;span style="font-style: italic;"&gt;A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;But all of the conditions below should hold for a deadlock to occur:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Mutual exclusion: Each resource is either currently assigned to exactly one process or is available.&lt;/li&gt;&lt;li&gt;Hold and wait: Processes currently holding resources that were granted earlier can request new resources&lt;/li&gt;&lt;li&gt;No preemption: Resources already granted cannot be forcibly taken away from a process. (The process has to explicitly release them.)&lt;/li&gt;&lt;li&gt;Circular wait: There must be a circular chain of two or more processes, each of which is waiting for a resource held  by the next member of the chain.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;The 'directed graph' technique is used to model these conditions. All approaches that attempt to prevent deadlocks try and eliminate one or more of the above conditions.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-2226702123174680263?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/2226702123174680263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/07/deadlocks.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2226702123174680263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2226702123174680263'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/07/deadlocks.html' title='Deadlocks'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-1029674764664153785</id><published>2010-01-08T07:18:00.004+05:30</published><updated>2010-01-08T08:17:38.111+05:30</updated><title type='text'>The microkernel design of Minix</title><content type='html'>In a monolithic OS, the entire OS is in a single process. &lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;But Minix has a microkernel design in which the operating system is composed of a set of processes (the kernel being just one of them) that work together by passing messages to each other. In this case it becomes necessary to distinguish between &lt;span style="font-weight: bold;"&gt;'system calls'&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;'kernel calls'&lt;/span&gt;. Unlike in a monolithic OS, user processes in Minix do not request services directly from the kernel. System calls from user processes result in 'messages' to the server processes (File System, Process Manager etc.). In turn, the server processes communicate with each other, the device drivers and with the kernel again using 'messages'. These messages to the kernel are really the 'kernel calls'. User processes do not have the privileges to make kernel calls.&lt;br /&gt;&lt;br /&gt;In summary, the conventional 'system call' in Minix results in one or more 'kernel calls' which will be initiated by either the server processes or device drivers. The ipc primitives: &lt;span style="font-family: arial;"&gt;send, receive &lt;span style="font-family: times new roman;"&gt;and &lt;/span&gt;notify&lt;/span&gt; are the 'infrastructure' on top of which kernel and system calls are built. The technical term for these ipc primitives is &lt;span style="font-weight: bold;"&gt;'traps'&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Tanenbaum gives a nice analogy to drive home the meaning of traps in Minix. The ipc primitive is like a carrier wave in a radio communications system. A &lt;span style="font-family: arial;"&gt;send&lt;/span&gt; message contains some data which conveys useful information to the receiving process. It is like a modulated radio wave. The &lt;span style="font-family: arial;"&gt;notify&lt;/span&gt; message conveys no information other than its origin. This is like an unmodulated radio wave (like a radio beacon that guides airplanes to an airport).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-1029674764664153785?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/1029674764664153785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/01/microkernel-design-of-minix.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/1029674764664153785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/1029674764664153785'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2010/01/microkernel-design-of-minix.html' title='The microkernel design of Minix'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-7936282324273752288</id><published>2009-12-11T23:55:00.003+05:30</published><updated>2009-12-11T23:59:58.382+05:30</updated><title type='text'>The Minix Process Table</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7sXqWG_R86A/SyKPllmX1_I/AAAAAAAACrc/jPUw7BWs_WM/s1600-h/processTable.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 200px;" src="http://2.bp.blogspot.com/_7sXqWG_R86A/SyKPllmX1_I/AAAAAAAACrc/jPUw7BWs_WM/s320/processTable.JPG" alt="" id="BLOGGER_PHOTO_ID_5414047577963747314" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The complete state of a process is defined by the process' data in memory, plus the information in its process table slot. See picture for details.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-7936282324273752288?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/7936282324273752288/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/12/minix-process-table.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/7936282324273752288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/7936282324273752288'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/12/minix-process-table.html' title='The Minix Process Table'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7sXqWG_R86A/SyKPllmX1_I/AAAAAAAACrc/jPUw7BWs_WM/s72-c/processTable.JPG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-3938823013150251487</id><published>2009-12-10T10:43:00.004+05:30</published><updated>2009-12-10T10:47:15.493+05:30</updated><title type='text'>Minix Kernel Data Structures</title><content type='html'>While studing the kernel data structures, it is a pain to go back and keep referring to the source in order to visualize the inter-relationships and references among the various pieces of data. I am currently working on some diagrams that will make it easier to visualize the layout of data in the kernel. I hope to upload these diagrams this weekend.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-3938823013150251487?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/3938823013150251487/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/12/minix-kernel-data-structures.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/3938823013150251487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/3938823013150251487'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/12/minix-kernel-data-structures.html' title='Minix Kernel Data Structures'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-7019736112984232348</id><published>2009-11-08T17:54:00.002+05:30</published><updated>2009-11-08T17:57:14.236+05:30</updated><title type='text'>Have been busy</title><content type='html'>I have been busy for a few weeks. Work from my day job has picked up and I am short staffed. Too many night phone calls. Too many meetings. No time to do anything worthwhile. I hope to fix the staffing situation at my work place and then get back to Minix after that. It is a real bummer. I was on a roll.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-7019736112984232348?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/7019736112984232348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/11/have-been-busy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/7019736112984232348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/7019736112984232348'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/11/have-been-busy.html' title='Have been busy'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-1138572228711915399</id><published>2009-10-08T11:33:00.004+05:30</published><updated>2009-10-08T11:38:34.937+05:30</updated><title type='text'>The heart of Minix</title><content type='html'>The 'save' assembly function in /src/kernel/mpx386.s is really the heart of the Minix OS. Discovering and understanding this function is like finding the holy grail. 'save' does some magical things. It doesn't follow any rules. It lives in its own world :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-1138572228711915399?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/1138572228711915399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/10/heart-of-minix.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/1138572228711915399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/1138572228711915399'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/10/heart-of-minix.html' title='The heart of Minix'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-8707125264812756686</id><published>2009-10-06T22:28:00.003+05:30</published><updated>2009-10-06T22:33:43.887+05:30</updated><title type='text'>Coding on bare metal</title><content type='html'>Went through the startup process in the Minix book again. It makes more sense now. The next section explains interrupt processing excellently. This is where we really begin to understand how the illusion of multiple processes is created.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-8707125264812756686?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/8707125264812756686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/10/bare-metal-coding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8707125264812756686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8707125264812756686'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/10/bare-metal-coding.html' title='Coding on bare metal'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-4954098032681358094</id><published>2009-10-01T17:20:00.004+05:30</published><updated>2009-10-06T22:28:11.288+05:30</updated><title type='text'>vish is a little closer to looking normal</title><content type='html'>One of the good engineers I know found out why my shell is not able to deal with commands without absolute path names. The problem was that I was using the wrong flavor of exec. Now that I am using execvp, this issue is resolved. execvp searches for the executable in the directories that are listed in the PATH env variable. Thanks Linu.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-4954098032681358094?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/4954098032681358094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/10/vish-is-little-closer-to-looking-normal.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4954098032681358094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4954098032681358094'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/10/vish-is-little-closer-to-looking-normal.html' title='vish is a little closer to looking normal'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-4537734641565635702</id><published>2009-09-28T19:55:00.002+05:30</published><updated>2009-09-28T20:07:26.959+05:30</updated><title type='text'>Minix Startup</title><content type='html'>Just slogged through the OS &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;startup&lt;/span&gt; process in The &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Minix&lt;/span&gt; Book. Could not understand some things in the first pass. I will have to re-read. In order to understand this section, I had to go back and revise assembler syntax and also how programs are laid out in memory. These topics led me to other related topics and I spent quite some time today reading all kinds of stuff. Ultimately I 'unwound the stack' and came back to The &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;Minix&lt;/span&gt; Book but I am still not satisfied. I find the kernel initialization process quite tough to grasp. I have to keep reminding myself that since the system is not yet fully initialized, concepts like files and processes don't even exist. All we have is a processor with registers, memory and kernel data structures. It is getting really steep here. But this is probably the most important part of this book. I have to keep my focus and keep working through it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-4537734641565635702?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/4537734641565635702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/09/minix-startup.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4537734641565635702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4537734641565635702'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/09/minix-startup.html' title='Minix Startup'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-8530553839969592700</id><published>2009-09-16T17:13:00.002+05:30</published><updated>2009-09-16T17:18:20.088+05:30</updated><title type='text'>Made some improvements to vish</title><content type='html'>I had forgotten to handle the possibility of no user input i.e. the user just pressing enter at the vish prompt. I took care of that today. I also found an issue that was being caused by not setting a pointer to NULL after freeing it. (The pointer variable was being reused in a loop.)&lt;br /&gt;&lt;br /&gt;Finally, I had to make a minor change in order to account for some of the quirks in the behaviour of strtok().&lt;br /&gt;&lt;br /&gt;I think vish is a lot more robust now. But it still does not handle cd, pwd, input and output redirection etc. Will get around to it later as I need to spend time studying the Minix kernel source.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-8530553839969592700?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/8530553839969592700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/09/made-some-improvements-to-vish.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8530553839969592700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8530553839969592700'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/09/made-some-improvements-to-vish.html' title='Made some improvements to vish'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-2620643567253893695</id><published>2009-08-30T05:27:00.004+05:30</published><updated>2009-08-30T05:40:08.963+05:30</updated><title type='text'>vish is alive and kicking butt!</title><content type='html'>&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;vish&lt;/span&gt; works great! Feels good. The data corruption had nothing to do with fork(). It was happening because I was trying to hold on to some data on the stack! I must be getting old. Need to work the pipe facility and possibly &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;wildcards&lt;/span&gt; into this new shell.&lt;br /&gt;&lt;br /&gt;Also, even though I am passing the environment string array into &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;execve&lt;/span&gt;(), it does not seem to use it and is forcing me to supply full path names of commands I want to execute. Will figure out what is going on later. For now, this is a good point to break and move on to later topics in the book (process management etc.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-2620643567253893695?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/2620643567253893695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/vish-is-alive-and-kicking-butt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2620643567253893695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/2620643567253893695'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/vish-is-alive-and-kicking-butt.html' title='vish is alive and kicking butt!'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-8128339475023392505</id><published>2009-08-23T16:02:00.002+05:30</published><updated>2009-08-23T16:07:20.510+05:30</updated><title type='text'>Writing a new shell</title><content type='html'>So I started writing my own shell called '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;vish&lt;/span&gt;'. Lots of issues. The '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;execve&lt;/span&gt;' system call does not seem to work consistently. I tried to track down the problem and what I found is this: I have a pointer to an array of strings which represent the command arguments that the user types in. I am using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;strtok&lt;/span&gt; to parse user input and build this structure. But as soon as I call fork(), this data structure is getting corrupted in both the parent and child processes. This just does not make any sense. Will get back and take a closer look.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-8128339475023392505?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/8128339475023392505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/writing-new-shell.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8128339475023392505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/8128339475023392505'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/writing-new-shell.html' title='Writing a new shell'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-6708001692606410424</id><published>2009-08-16T17:16:00.003+05:30</published><updated>2009-08-17T10:55:00.777+05:30</updated><title type='text'>Process Scheduling</title><content type='html'>Just went through various algorithms for process scheduling. The one that really interests me is Lottery Scheduling. Can't wait to get into how exactly scheduling is implemented in &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Minix&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;On an unrelated note,  I am about to start writing my own shell. Think I will call it &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;vish&lt;/span&gt;! I guess this shell could produce error messages that start with "You &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;vish&lt;/span&gt;".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-6708001692606410424?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/6708001692606410424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/process-scheduling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/6708001692606410424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/6708001692606410424'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/process-scheduling.html' title='Process Scheduling'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-9148673453221790380</id><published>2009-08-10T06:04:00.002+05:30</published><updated>2009-08-10T06:08:59.028+05:30</updated><title type='text'>Programming with semaphores</title><content type='html'>Just studied the different examples on using semaphores in the Tanenbaum book. Consider a non-trivial one like the solution given for the Dining Philosopher's problem. Sitting and staring at the algorithm for hours helps you understand it but not in such a way that you can recall it at a later time. Nor is it easy to find flaws in these algorithms just by inspection. I think that the only way to get good at using semaphores intelligently is to spend lots of time programming and debugging with them. If you don't use it you lose it.&lt;br /&gt;&lt;br /&gt;Race conditions are painful because of their unpredictability.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-9148673453221790380?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/9148673453221790380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/programming-with-semaphores.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/9148673453221790380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/9148673453221790380'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/programming-with-semaphores.html' title='Programming with semaphores'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-4805383496931327728</id><published>2009-08-04T09:55:00.003+05:30</published><updated>2009-08-04T10:00:17.850+05:30</updated><title type='text'>Semaphores</title><content type='html'>But then, race conditions can happen in Petersen's approach too and even in the sleep/&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;wake-up&lt;/span&gt; approach suggested in the producer-consumer (which share a read-write buffer) problem. That is where &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Djikstra's&lt;/span&gt; semaphores come in. Semaphores basically keep track of pending wake-up calls and account for each of them. Semaphore 'ups/downs' are analogous to 'wake-ups/sleeps' in the producer-consumer problem.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-4805383496931327728?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/4805383496931327728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/but-then-race-conditions-can-happen-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4805383496931327728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/4805383496931327728'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/but-then-race-conditions-can-happen-in.html' title='Semaphores'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-7974645266307060299</id><published>2009-08-03T12:15:00.002+05:30</published><updated>2009-08-03T13:42:15.294+05:30</updated><title type='text'>Cooperating processes</title><content type='html'>I am currently reading about different approaches to ensure protection of shared resources in a system that supports multiples processes: the concept of mutual exclusion. Petersen's approach is very simple and elegant. A variant of this relies on the hardware by using the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;TSL&lt;/span&gt; hardware instruction. Fun stuff.&lt;br /&gt;&lt;br /&gt;I also wrote and tested a C program that tests most of the system calls on Ubuntu Linux 9.0.4. It was a great experience. The actual exercise is to test this on Minix but I don't yet have a machine on which I can install and play with Minix.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-7974645266307060299?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/7974645266307060299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/cooperating-processes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/7974645266307060299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/7974645266307060299'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/08/cooperating-processes.html' title='Cooperating processes'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5313249829740971301.post-5900495238127822880</id><published>2009-07-27T09:57:00.003+05:30</published><updated>2009-07-27T10:04:06.071+05:30</updated><title type='text'>Hardware Interrupts</title><content type='html'>Back to the basics! I want to plug holes in my knowledge so I am currently studying Tanenbaum's 'Operating Systems: Design and Implementation' also known as The Minix Book.&lt;br /&gt;&lt;br /&gt;The topic is 'hardware interrupts'. This concept is a little difficult to understand for an application programmer who takes many things about the hardware and software for granted. Tanenbaum explains it well but I had to read it multiple times to grasp it. One reason is that the author does not provide a diagram to illustrate what happens when a hardware interrupt occurs. Maybe I will create one and post it here!&lt;br /&gt;&lt;br /&gt;Comments welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5313249829740971301-5900495238127822880?l=vishy-ranganath.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vishy-ranganath.blogspot.com/feeds/5900495238127822880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/07/hardware-interrupts.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/5900495238127822880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5313249829740971301/posts/default/5900495238127822880'/><link rel='alternate' type='text/html' href='http://vishy-ranganath.blogspot.com/2009/07/hardware-interrupts.html' title='Hardware Interrupts'/><author><name>Vishy Ranganath</name><uri>http://www.blogger.com/profile/11357138041307857124</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://1.bp.blogspot.com/_7sXqWG_R86A/TCvsZGT3ICI/AAAAAAAAGh8/q4yjYq8528w/S220/Vishy+face+4.JPG'/></author><thr:total>2</thr:total></entry></feed>
