CS330 · Chapter 3 · Annotated SlidesProcess Management
Original
Overview

Process Management

The process concept and its memory layout, process states and the PCB, scheduling queues and schedulers, context switches, process creation (fork/exec) and termination, and interprocess communication with shared memory (bounded buffer) and message passing.

How to read this page

Every original slide is shown unchanged. Yellow marks on a slide point to a numbered note: hover or tap a mark to jump to its note, and hover a note to see its marks. Questions tagged Past exam appeared on a real paper; Prediction questions are likely angles, not confirmed. Pick an answer to each question: a wrong pick tells you why it is wrong, so you can try again.

All 48 slides
  1. 1 Chapter 3: Processes
  2. 2 Outline
  3. 3 Objectives
  4. 4 Process Concept
  5. 5 Process Concept (Cont.)
  6. 6 Process in Memory
  7. 7 Process State
  8. 8 Diagram of Process State
  9. 9 Process Control Block (PCB)
  10. 10 Process Control Block (PCB)
  11. 11 Threads
  12. 12 Process Representation in Linux
  13. 13 Process Scheduling
  14. 14 Ready and Wait Queues
  15. 15 Representation of Process Scheduling
  16. 16 Schedulers
  17. 17 Addition of Medium Term Scheduling
  18. 18 Schedulers (Cont.)
  19. 19 Context Switch
  20. 20 CPU Switch From Process to Process
  21. 21 Operations on Processes
  22. 22 Process Creation
  23. 23 Process Creation (Cont.)
  24. 24 A Tree of Processes in Linux
  25. 25 C Program Forking Separate Process
  26. 26 Creating a Separate Process via Windows API
  27. 27 Process Termination
  28. 28 Process Termination
  29. 29 Android Process Importance Hierarchy
  30. 30 Multiprocess Architecture – Chrome Browser
  31. 31 Interprocess Communication
  32. 32 Communications Models
  33. 33 Producer-Consumer Problem
  34. 34 IPC – Shared Memory
  35. 35 Bounded-Buffer – Shared-Memory Solution
  36. 36 Producer Process – Shared Memory
  37. 37 Consumer Process – Shared Memory
  38. 38 What about Filling all the Buffers?
  39. 39 Producer
  40. 40 Consumer
  41. 41 IPC – Message Passing
  42. 42 Message Passing (Cont.)
  43. 43 Implementation of Communication Link
  44. 44 Direct Communication
  45. 45 Indirect Communication
  46. 46 Indirect Communication (Cont.)
  47. 47 Indirect Communication (Cont.)
  48. 48 Slide 48
Slide 1 / 48

Chapter 3: Processes

Slide 1: Chapter 3: Processes
Slide 2 / 48

Outline

Slide 2: Outline
Slide 3 / 48

Objectives

Slide 3: Objectives
Slide 4 / 48

Process Concept

Slide 4: Process Concept
Slide 5 / 48

Process Concept (Cont.)

Slide 5: Process Concept (Cont.)
Slide 6 / 48

Process in Memory

Slide 6: Process in Memory

Notes

  1. Memory layout from low to high: text, data, heap (grows up) … stack (grows down).

Exam angle

PredictionQ1

Local variables and return addresses are stored in the process’s:

Slide 7 / 48

Process State

Slide 7: Process State
Slide 8 / 48

Diagram of Process State

Slide 8: Diagram of Process State

Notes

  1. Transitions: ready → running (dispatch), running → ready (interrupt), running → waiting (I/O or event wait), waiting → ready (I/O done).

  2. Trap A waiting process goes to READY when its I/O completes, never straight to running.

Exam angle

PredictionQ1

When a process’s I/O completes, it moves from waiting to:

Slide 9 / 48

Process Control Block (PCB)

Slide 9: Process Control Block (PCB)

Exam angle

PredictionQ1

Which is NOT stored in a PCB?

Slide 10 / 48

Process Control Block (PCB)

Slide 10: Process Control Block (PCB)
Slide 11 / 48

Threads

Slide 11: Threads
Slide 12 / 48

Process Representation in Linux

Slide 12: Process Representation in Linux
Slide 13 / 48

Process Scheduling

Slide 13: Process Scheduling
Slide 14 / 48

Ready and Wait Queues

Slide 14: Ready and Wait Queues

Notes

  1. Ready queue: processes in memory waiting for the CPU. Wait queues: waiting for an event or device.

Slide 15 / 48

Representation of Process Scheduling

Slide 15: Representation of Process Scheduling
Slide 16 / 48

Schedulers

Slide 16: Schedulers

Notes

  1. Short-term (CPU) scheduler: picks the next ready process, runs very often. Long-term (job) scheduler: controls the degree of multiprogramming.

Exam angle

PredictionQ1

The scheduler that controls the degree of multiprogramming is the:

Slide 17 / 48

Addition of Medium Term Scheduling

Slide 17: Addition of Medium Term Scheduling

Notes

  1. Medium-term scheduler: swaps processes out of memory and back in to reduce the degree of multiprogramming.

Slide 18 / 48

Schedulers (Cont.)

Slide 18: Schedulers (Cont.)

Notes

  1. I/O-bound processes: many short CPU bursts. CPU-bound: few long bursts. A good mix keeps both CPU and devices busy.

Slide 19 / 48

Context Switch

Slide 19: Context Switch

Exam angle

PredictionQ1

During a context switch the system does useful work for the processes.

Slide 20 / 48

CPU Switch From Process to Process

Slide 20: CPU Switch From Process to Process
Slide 21 / 48

Operations on Processes

Slide 21: Operations on Processes
Slide 22 / 48

Process Creation

Slide 22: Process Creation
Slide 23 / 48

Process Creation (Cont.)

Slide 23: Process Creation (Cont.)

Notes

  1. UNIX: fork() makes a copy of the parent; exec() replaces the child’s memory with a new program; wait() lets the parent wait.

Exam angle

PredictionQ1

After fork(), the return value in the child process is:

Slide 24 / 48

A Tree of Processes in Linux

Slide 24: A Tree of Processes in Linux
Slide 25 / 48

C Program Forking Separate Process

Slide 25: C Program Forking Separate Process
Slide 26 / 48

Creating a Separate Process via Windows API

Slide 26: Creating a Separate Process via Windows API
Slide 27 / 48

Process Termination

Slide 27: Process Termination

Notes

  1. exit() ends a process; the parent collects the status with wait(). Zombie: terminated but parent hasn’t called wait(). Orphan: parent ended without waiting.

Exam angle

PredictionQ1

A process that has terminated but whose parent has not yet called wait() is a:

Slide 28 / 48

Process Termination

Slide 28: Process Termination
Slide 29 / 48

Android Process Importance Hierarchy

Slide 29: Android Process Importance Hierarchy
Slide 30 / 48

Multiprocess Architecture – Chrome Browser

Slide 30: Multiprocess Architecture – Chrome Browser
Slide 31 / 48

Interprocess Communication

Slide 31: Interprocess Communication
Slide 32 / 48

Communications Models

Slide 32: Communications Models

Notes

  1. Two IPC models: shared memory (fast, processes synchronize themselves) and message passing (kernel involved, easier for small data and distributed systems).

Exam angle

PredictionQ1

Which IPC model is usually faster once set up?

Slide 33 / 48

Producer-Consumer Problem

Slide 33: Producer-Consumer Problem
Slide 34 / 48

IPC – Shared Memory

Slide 34: IPC – Shared Memory
Slide 35 / 48

Bounded-Buffer – Shared-Memory Solution

Slide 35: Bounded-Buffer – Shared-Memory Solution

Notes

  1. Circular bounded buffer: in = next free slot, out = first full slot. Empty when in out; full when (in + 1) % SIZE out, so only SIZE − 1 items fit.

Exam angle

PredictionQ1

With the in/out bounded-buffer solution and BUFFER_SIZE = 10, at most how many items can be in the buffer?

Slide 36 / 48

Producer Process – Shared Memory

Slide 36: Producer Process – Shared Memory
Slide 37 / 48

Consumer Process – Shared Memory

Slide 37: Consumer Process – Shared Memory
Slide 38 / 48

What about Filling all the Buffers?

Slide 38: What about Filling all the Buffers?

Notes

  1. Adding a count variable lets all slots be used, but count++ / count-- then need synchronization (race condition → Ch 6).

  2. Seen again Chapter 6: Synchronization, slide 6: the race on count

Slide 39 / 48

Producer

Slide 39: Producer
Slide 40 / 48

Consumer

Slide 40: Consumer
Slide 41 / 48

IPC – Message Passing

Slide 41: IPC – Message Passing
Slide 42 / 48

Message Passing (Cont.)

Slide 42: Message Passing (Cont.)
Slide 43 / 48

Implementation of Communication Link

Slide 43: Implementation of Communication Link
Slide 44 / 48

Direct Communication

Slide 44: Direct Communication
Slide 45 / 48

Indirect Communication

Slide 45: Indirect Communication

Notes

  1. Indirect communication: send to / receive from a mailbox (port); a link can join many processes.

Exam angle

PredictionQ1

In indirect communication, messages are sent to:

Slide 46 / 48

Indirect Communication (Cont.)

Slide 46: Indirect Communication (Cont.)
Slide 47 / 48

Indirect Communication (Cont.)

Slide 47: Indirect Communication (Cont.)

Notes

  1. Blocking (synchronous) vs. non-blocking (asynchronous) send and receive. Blocking send + blocking receive = rendezvous.

Slide 48 / 48

Slide 48

Slide 48: Slide 48