------------------------------------------------------ Lecture 04 - February 10, 2003 ------------------------------------------------------ AGENDA: 0 Admin 1 P1: last chance for questions 2 P2: version 2 of the shell 3 Ch 2.1: introduction to processes 4 Ch 2.2: interprocess communication ------------------------------------------------------ 0 - ADMIN ------------------------------------------------------ Startout Q: What is a process? Wednesday: * RI #2 * email to cos421gr@css.tayloru.edu * Give you the grade/feedback on P1 Friday: * HM #2 * Quiz #2 Bochs/MINIX installation: thoughts from Thomas Hruska "I got it to work. The following link points at a series of floppy images of Minix and a few batch files. Once I figured out the partition problem (I did not partition correctly), Bochs and Minix work flawlessly. The following link only works ON CAMPUS: \\10.5.228.98\Programs\SOURCE\OS\MINIX\2.0.3\BUILDIMG The readme.txt file documents how to create an image. I created the floppy images using a FreeDOS utility called raread (the counterpart to the infamous utility rawrite). The floppy images drastically improve the overall speed of installation (zoom, zoom!!!)." ------------------------------------------------------ 1 - P1: LAST CHANCE FOR QUESTIONS ------------------------------------------------------ This is the time and place. ------------------------------------------------------ 2 - P2: OVERVIEW OF V.2 OF SHELL ------------------------------------------------------ Go over shell description on web. Describe file descriptors * index into "open files" table for process * fd 0 == stdin - by default the keyboard fd 1 == stdout - by default the terminal screen fd 2 == stderr - "" "" * open files and the corresponding file descriptors are preserved across a fork or exec command * EOF is not detected until the reference count to the writing end of the pipe is 0. Until that time, it is possible that a program could write more data. * read 1.4.3 for explanations and sample code signals: check out ------------------------------------------------------ 3 - CH 2.1 - INTRODUCTION TO PROCESSES ------------------------------------------------------ process: an abstraction of a running program * an executing program * also all relevant supporting data - program counter, registers, variables pseudoparallelism: faking multiprocessor behavior process vs. program process hierarchies (incl. init) process states * running, blocked, ready Implementing processes * process table fig 2-4 p, 53 * interrupt vector & interrupt service routine fig 2-5 p. 54 threads * single vs. multiple threads of control and program counter * also called lightweight processes * do they share the same address space? * user-space vs. kernel control * issue of what all is blocked when a thread blocks Considerations in thread management ------------------------------------------------------ 3 - CH 2.2 - INTERPROCESS COMMUNICATION ------------------------------------------------------ aka IPC can use interrupts, but very primitive Interprocess communication 3 issues * how can processes pass information to each other * ensuring that processes do not get in each other's way during critical activities * ensuring proper sequencing when have dependencies RACE CONDITIONS * Spooler directory example fig 2-7 p. 58. * Two processes end up both trying to write a file to same slot. * All sorts of similar problems occur. Only one time in 1000 (or greater) might there be a problem, but that will drive you crazy. CRITICAL SECTIONS * Times when need guarantee that nobody else will get in to the same data structure and mess around at the same time. * Need mutual exclusion. * Aka critical region. Four conditions for good solution 1) no two processes may be simultaneously inside their critical regions 2) no assumptions may be made about speeds or the number of CPUs 3) no process running outside its critical region may block other processes 4) no process should have to wait forever to enter its critical region COS 421 - Lecture Notes #4 SPRING 2003 COS421-lect-2003-02-10.doc Page 1 Printed 10.02.03