lecture operating system chapter 02 - Processes and Threads University of technology

55 411 0
lecture operating system chapter 02 - Processes and Threads University of technology

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

1 Processes and Threads Chapter 2 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling 2 Processes The Process Model • Multiprogramming of four programs • Conceptual model of 4 independent, sequential processes • Only one program active at any instant 3 Process Creation Principal events that cause process creation 1. System initialization • Execution of a process creation system 1. User request to create a new process 2. Initiation of a batch job 4 Process Termination Conditions which terminate processes 1. Normal exit (voluntary) 2. Error exit (voluntary) 3. Fatal error (involuntary) 4. Killed by another process (involuntary) 5 Process Hierarchies • Parent creates a child process, child processes can create its own process • Forms a hierarchy – UNIX calls this a "process group" • Windows has no concept of process hierarchy – all processes are created equal 6 Process States (1) • Possible process states – running – blocked – ready • Transitions between states shown 7 Process States (2) • Lowest layer of process-structured OS – handles interrupts, scheduling • Above that layer are sequential processes 8 Implementation of Processes (1) Fields of a process table entry 9 Implementation of Processes (2) Skeleton of what lowest level of OS does when an interrupt occurs 10 Threads The Thread Model (1) (a) Three processes each with one thread (b) One process with three threads [...]... construct a server 16 Implementing Threads in User Space A user-level threads package 17 Implementing Threads in the Kernel A threads package managed by the kernel 18 Hybrid Implementations Multiplexing user-level threads onto kernel- level threads 19 Scheduler Activations • Goal – mimic functionality of kernel threads – gain performance of user space threads • Avoids unnecessary user/kernel transitions •... runtime system allocate threads to processors • Problem: Fundamental reliance on kernel (lower layer) calling procedures in user space (higher layer) 20 Pop-Up Threads • Creation of a new thread when message arrives (a) before message arrives (b) after message arrives 21 Making Single-Threaded Code Multithreaded (1) Conflicts between threads over the use of a global variable 22 Making Single-Threaded... Exclusion with Busy Waiting (3) Entering and leaving a critical region using the TSL instruction 29 Sleep and Wakeup Producer-consumer problem with fatal race condition 30 Semaphores The producer-consumer problem using semaphores 31 Mutexes Implementation of mutex_lock and mutex_unlock 32 Monitors (1) Example of a monitor 33 Monitors (2) • Outline of producer-consumer problem with monitors – only one... Making Single-Threaded Code Multithreaded (2) Threads can have private global variables 23 Interprocess Communication Race Conditions Two processes want to access shared memory at same time 24 Critical Regions (1) Four conditions to provide mutual exclusion 1 2 3 4 No two processes simultaneously in critical region No assumptions made about speeds or numbers of CPUs No process running outside its critical... shared by all threads in a process • Items private to each thread 11 The Thread Model (3) Each thread has its own stack 12 Thread Usage (1) A word processor with three threads 13 Thread Usage (2) A multithreaded Web server 14 Thread Usage (3) • Rough outline of code for previous slide (a) Dispatcher thread (b) Worker thread 15 Thread Usage (4) Three ways to construct a server 16 Implementing Threads in... Monitors (2) • Outline of producer-consumer problem with monitors – only one monitor procedure active at one time – buffer has N slots 34 Monitors (3) Solution to producer-consumer problem in Java (part 1) 35 Monitors (4) Solution to producer-consumer problem in Java (part 2) 36 . layer of process-structured OS – handles interrupts, scheduling • Above that layer are sequential processes 8 Implementation of Processes (1) Fields of a process table entry 9 Implementation of. Implementations Multiplexing user-level threads onto kernel- level threads 20 Scheduler Activations • Goal – mimic functionality of kernel threads – gain performance of user space threads • Avoids. model of 4 independent, sequential processes • Only one program active at any instant 3 Process Creation Principal events that cause process creation 1. System initialization • Execution of a

Ngày đăng: 18/10/2014, 15:30

Từ khóa liên quan

Mục lục

  • Processes and Threads

  • Processes The Process Model

  • Process Creation

  • Process Termination

  • Process Hierarchies

  • Process States (1)

  • Process States (2)

  • Implementation of Processes (1)

  • Implementation of Processes (2)

  • Threads The Thread Model (1)

  • The Thread Model (2)

  • The Thread Model (3)

  • Thread Usage (1)

  • Thread Usage (2)

  • Thread Usage (3)

  • Thread Usage (4)

  • Implementing Threads in User Space

  • Implementing Threads in the Kernel

  • Hybrid Implementations

  • Scheduler Activations

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan