1. Trang chủ
  2. » Công Nghệ Thông Tin

slide operating system chapter 2

92 18 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 92
Dung lượng 2,6 MB

Nội dung

Chapter Processes and Threads 2.1 Processes 2.2 Threads 2.3 Scheduling 2.4 Interprocess communication CuuDuongThanCong.com https://fb.com/tailieudientucntt 2.1 Processes CuuDuongThanCong.com https://fb.com/tailieudientucntt Processes The Process Model • (a) Multiprogramming of four programs • (b) Conceptual model of independent, sequential processes • (c) Only one program active at any instant CuuDuongThanCong.com https://fb.com/tailieudientucntt Processes Process Concept • An operating system executes a variety of programs: – Batch system – jobs – Time-shared systems – user programs or tasks • Process – a program in execution; process execution must progress in sequential fashion • A process resources includes: – Address space (text segment, data segment) – CPU (virtual) • program counter • registers • stack – Other resource (open files, child processes…) CuuDuongThanCong.com https://fb.com/tailieudientucntt Processes Process in Memory CuuDuongThanCong.com https://fb.com/tailieudientucntt Processes Process Creation (1) Principal events that cause process creation System initialization Execution of a process creation system Call User request to create a new process Initiation of a batch job CuuDuongThanCong.com https://fb.com/tailieudientucntt Processes Process Creation (2) • Address space – Child duplicate of parent – Child has a program loaded into it • UNIX examples – fork system call creates new process – exec system call used after a fork to replace the process’ memory space with a new program CuuDuongThanCong.com https://fb.com/tailieudientucntt Processes Process Creation (3) : Example CuuDuongThanCong.com https://fb.com/tailieudientucntt Processes Process Termination Conditions which terminate processes Normal exit (voluntary) Error exit (voluntary) Fatal error (involuntary) Killed by another process (involuntary) CuuDuongThanCong.com https://fb.com/tailieudientucntt Processes 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 CuuDuongThanCong.com https://fb.com/tailieudientucntt 10 Synchronous solution with Sleep & Wakeup – Semaphore – Monitor – Message passing CuuDuongThanCong.com https://fb.com/tailieudientucntt 78 "Sleep & Wake up" solution , • Give up CPU when not come in CS • When CS is empty, will be waken up to come in CS • Need support of OS – Because of changing status of process CuuDuongThanCong.com https://fb.com/tailieudientucntt 79 "Sleep & Wake up" solution: Idea • OS support primitive: – Sleep(): System call receives blocked status – WakeUp(P): P process receive ready status • Application – After checking condition, coming in CS or calling Sleep() depend on result of checking – Process that using CS before, will wake up processes blocked before CuuDuongThanCong.com https://fb.com/tailieudientucntt 80 Apply Sleep() and Wakeup() CuuDuongThanCong.com https://fb.com/tailieudientucntt 81 Problem with Sleep & WakeUp • Reason: – Checking condition and giving up CPU can be broken – Lock variable is not protected CuuDuongThanCong.com https://fb.com/tailieudientucntt 82 Synchronous solution with Sleep & Wakeup Semaphore • Suggested by Dijkstra, 1965 • Properties: Semaphore s; – Unique value – Manipulate with primitives: • Down(s) • Up(s) – Down and Up primitives executed cannot divide up CuuDuongThanCong.com https://fb.com/tailieudientucntt 83 Synchronous solution with Sleep & Wakeup Install Semaphore (Sleep & Wakeup) CuuDuongThanCong.com https://fb.com/tailieudientucntt 84 Synchronous solution with Sleep & Wakeup Install Semaphore (Sleep & Wakeup) CuuDuongThanCong.com https://fb.com/tailieudientucntt 85 Synchronous solution with Sleep & Wakeup Using Semaphore CuuDuongThanCong.com https://fb.com/tailieudientucntt 86 Synchronous solution with Sleep & Wakeup Monitor • Hoare (1974) & Brinch (1975) • Synchronous mechanism is provided by programming language – Support with functions, such as Semaphore – Easier for using and detecting than Semaphore • Ensure Mutual Exclusion automatically • Using condition variable to perform Synchronization CuuDuongThanCong.com https://fb.com/tailieudientucntt 87 Synchronous solution with Sleep & Wakeup Monitor: structure CuuDuongThanCong.com https://fb.com/tailieudientucntt 88 Synchronous solution with Sleep & Wakeup Monitor: structure monitor monitor-name { shared variable declarations procedure body P1 (…) { } procedure body P2 (…) { } procedure body Pn (…) { } { initialization code } } CuuDuongThanCong.com https://fb.com/tailieudientucntt 89 Synchronous solution with Sleep & Wakeup Using Monitor CuuDuongThanCong.com https://fb.com/tailieudientucntt 90 Synchronous solution with Sleep & Wakeup Message Passing • Processes must name each other explicitly: – send (P, message) – send a message to process P – receive(Q, message) – receive a message from process Q • Properties of communication link – Links are established automatically – A link is associated with exactly one pair of communicating processes – Between each pair there exists exactly one link – The link may be unidirectional, but is usually bidirectional CuuDuongThanCong.com https://fb.com/tailieudientucntt 91 Classical Problems of Synchronization • Bounded-Buffer Problem (Producer-Consumer Problem) • Readers and Writers Problem • Dining-Philosophers Problem CuuDuongThanCong.com https://fb.com/tailieudientucntt 92 ... P2 24 P3 27 30 • Waiting time for P1 = 0; P2 = 24 ; P3 = 27 • Average waiting time: (0 + 24 + 27 )/3 = 17 CuuDuongThanCong.com https://fb.com/tailieudientucntt 41 Scheduling Scheduling in Batch Systems... Interactive Systems (3) Example of RR with Time Quantum = 20 Process P1 P2 P3 P4 • The Gantt chart is: P1 P2 20 37 P3 Burst Time 53 17 68 24 P4 57 P1 77 P3 97 117 P4 P1 P3 P3 121 134 154 1 62 Typically,... Systems (1) First-Come, First-Served (FCFS) Scheduling Process Burst Time P1 24 P2 P3 • Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: P1 P2

Ngày đăng: 03/02/2021, 22:12

TỪ KHÓA LIÊN QUAN