Docsity

Operating Systems Lecture Notes: Processes, Slides of Operating Systems

Partial preview of the text

Download Operating Systems Lecture Notes: Processes and more Slides Operating Systems in PDF only on Docsity!

Operating Systems

LECTURE#

Processes Processes

Dr. Shariq BASHIR

[email protected]

Operating Systems

FALL 2019

Operating Systems

Course Learning Objectives

  1. Study the fundamental concepts of operating system design and implementation.
  2. Understand the interaction between user- level applications and the underlying operating system.
  3. Practical understanding of operating system topics such as processes/threads, file systems, and memory management.

Operating Systems 4

“ “TentativeTentative”” GradingGrading

  • (^) Assignments 15%
  • (^) Quizzes /Class Test 10%
  • (^) Midterm 25%
  • (^) Final Exam 50%

5

What If No Operating System? What If No Operating System?

  • (^) All we have is bare hardware
  • (^) You want to run a program  (^) How do you load it?  (^) How do you run it?  (^) What happens when it completes?
  • (^) Need at least some minimal Operating System (OS) to do these functions

Operating Systems

  • (^) A computer program in execution on a machine is a process
  • (^) More formally:
    • (^) A Sequential Stream of Execution in its own address space

Process

7

Operating SystemsControl Flow of a

Process

inst 1 inst 2 inst 3 … inst n

  • (^) Computers do Only One Thing
    • (^) From startup to shutdown, a CPU simply reads and executes a sequence of instructions, one at a time. Physical control flow Time

Operating Systems

Process Types

  • (^) If all processes are I/O bound,
    • (^) System will go free
  • (^) If all processes are CPU bound,
    • (^) Devices will go unused
    • (^) System will again be unbalanced 10

Operating Systems

How OS Creates a Process

  • (^) Assign a unique process identifier
  • (^) Allocate space to the process
  • (^) Creates process control block
    • (^) Ex: add new process to linked list used for scheduling processes

Operating SystemsPrivate Address Spaces of a

Process

  • (^) Each process has its own private address space Heap Segment run-time heap (managed by malloc) Stack Segment user stack (created at runtime) Code Segment 0 %esp (stack pointer) memory invisible to user code 0xc 0x 0x Data Segment loaded from the executable file 0xffffffff

Operating Systems

Five-State Process Model

New New Exit Exit Admit Release Running Running Ready Ready Dispatch Time-out Blocked Blocked Event occurs (^) Event wait 14

Operating Systems

CPU Switch From Process to

Process

  • (^) Part of OS (Operating System) responsible for switching the processor among the processes is called Dispatcher 16

Operating Systems

Context Switching Example

Tim eoutI/O Tim eout Tim eout

Operating Systems

Trace from Processors point of view

Tim eoutI/O Tim eout Tim eout

Operating Systems

  • (^) Processes may themselves go on to create new processes
  • (^) A new process is created by a fork() system call (in case of only linux) 20

Creating new Process