tailieunhanh - Lecture Operating system concepts - Lecture 8

After studying this chapter you will be able to develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks; to present a number of different methods for preventing or avoiding deadlocks in a computer system. | CSC 322 Operating Systems Concepts Lecture - 8: 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 No run-time system is needed Also, there is no thread table in each process. Threads do not require any new, non-blocking system calls. Context switching to threads is still possible in case of blocking system calls or event of page fault. Advantages; Implementing Threads in kernel space Lecture -8 Ahmed Mumtaz Mustehsan, CIIT, Islamabad 2 In addition to process table, kernel maintains thread-table, to keep track of all the threads in the system. To create a new or destroy existing thread, it makes a kernel call, which does the creation or destruction by updating the kernel thread table. All calls that might block a thread are implemented as system calls. If thread blocks, kernel just picks another one Not necessarily from same process! To save time recycling of threads | CSC 322 Operating Systems Concepts Lecture - 8: 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 No run-time system is needed Also, there is no thread table in each process. Threads do not require any new, non-blocking system calls. Context switching to threads is still possible in case of blocking system calls or event of page fault. Advantages; Implementing Threads in kernel space Lecture -8 Ahmed Mumtaz Mustehsan, CIIT, Islamabad 2 In addition to process table, kernel maintains thread-table, to keep track of all the threads in the system. To create a new or destroy existing thread, it makes a kernel call, which does the creation or destruction by updating the kernel thread table. All calls that might block a thread are implemented as system calls. If thread blocks, kernel just picks another one Not necessarily from same process! To save time recycling of threads is possible. Expensive to manage the threads in the kernel and takes valuable kernel space Implementing threads in kernel space Lecture -8 Ahmed Mumtaz Mustehsan, CIIT, Islamabad 3 kernel threads do not solve all problems! What happens when a multithreaded process forks (creates a child process)? Should child have the same number of threads? Signals are sent to processes, not to threads. When a signal comes in, which thread should handle it? The thread that register that? What if it clashes with another thread? Do Kernel Level Threads solve all the Problems? Lecture -8 Ahmed Mumtaz Mustehsan, CIIT, Islamabad 4 How do we get the advantages of both approaches, without the disadvantages? Multiplex user-level threads onto kernel level threads Programmer determines how many user level and how many kernel level threads to use. The threads expected to issue blocking system call could be made kernel level thread Kernel is aware of kernel threads only User level threads are scheduled, created .