In this chapter, we discuss various mechanisms to ensure the orderly execution of cooperating processes that share a logical address space, so that data consistency is maintained. | CSC 322 Operating Systems Concepts Lecture - 7: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. (Chapter-1) Ahmed Mumtaz Mustehsan, CIIT, Islamabad 1 Lecture 7 Ahmed Mumtaz Mustehsan, CIIT, Islamabad 2 Process and Thread Process has an address space and a single thread of control. Processes may have multiple threads of control in the same address space running in quasi-parallel, like (almost) separate processes. Threads are Processes with in process Threads are lightweight processes share the same address space and resources allocated to process. Process share the resources offered by operating system among other processes Lecture 7 Ahmed Mumtaz Mustehsan, CIIT, Islamabad 3 Usage of Threads Example: Processing a large document, having threads for, Interactive users, background formatter and backup file on disk . Thread Example-web server . Lecture 7 4 Ahmed Mumtaz Mustehsan, CIIT, Islamabad This model allows the . | CSC 322 Operating Systems Concepts Lecture - 7: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. (Chapter-1) Ahmed Mumtaz Mustehsan, CIIT, Islamabad 1 Lecture 7 Ahmed Mumtaz Mustehsan, CIIT, Islamabad 2 Process and Thread Process has an address space and a single thread of control. Processes may have multiple threads of control in the same address space running in quasi-parallel, like (almost) separate processes. Threads are Processes with in process Threads are lightweight processes share the same address space and resources allocated to process. Process share the resources offered by operating system among other processes Lecture 7 Ahmed Mumtaz Mustehsan, CIIT, Islamabad 3 Usage of Threads Example: Processing a large document, having threads for, Interactive users, background formatter and backup file on disk . Thread Example-web server . Lecture 7 4 Ahmed Mumtaz Mustehsan, CIIT, Islamabad This model allows the server to be written as a collection of sequential threads. (a) Dispatcher thread. (b) Worker thread. Web server code Lecture 7 5 Ahmed Mumtaz Mustehsan, CIIT, Islamabad In the absence of threads, web process operates as a single thread. If page is not there, then thread blocks CPU does nothing while it waits for page Server can handle fewer requests of the clients as compared to multithreaded implementation. Wastage of CPU time if the server is a dedicated web server Web server with single thread of control Lecture 7 6 Ahmed Mumtaz Mustehsan, CIIT, Islamabad If page is not there, the server switches to another event/request (use a non-blocking call) The state of the computation must be saved and restored in the table every time the server switches from one request to another. The next event may be a request for new work or a reply received through Interrupt-Signal from the disk about a previous operation. If it is new work, it is started, otherwise the relevant information is fetched from