Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Operating Systems: Introduction to Processes and Process Scheduling, Summaries of Process Control

A chapter from the textbook 'COP 4610: Introduction to Operating Systems' focusing on processes, their concept, scheduling, states, inter-process communication, and examples of IPC systems. It also covers communication in client-server systems and process control blocks in Linux.

Typology: Summaries

2021/2022

Uploaded on 09/27/2022

janet
janet 🇬🇧

3.3

(4)

252 documents

1 / 47

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COP 4610: Introduction to Operating Systems (Fall 2016)
Chapter 3: Process
Zhi Wang!
Florida State University
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f

Partial preview of the text

Download Operating Systems: Introduction to Processes and Process Scheduling and more Summaries Process Control in PDF only on Docsity!

COP 4610: Introduction to Operating Systems (Fall 2016)

Chapter 3: Process

Zhi Wang

Florida State University

Contents

• Process concept

• Process scheduling

• Operations on processes

• Inter-process communication

• examples of IPC Systems

• Communication in client-server systems

Process Concept

• A process has multiple parts:

• the program code , also called text section

• runtime CPU states , including program counter, registers, etc

• various types of memory:

• stack : temporary data

• e.g., function parameters, local variables, and return addresses

• data section: global variables

• heap : memory dynamically allocated during runtime

Process in Memory

Diagram of Process State

Process Control Block (PCB)

• In the kernel, each process is associated with a process control block

• process number (pid)

• process state

• program counter

• CPU registers

• CPU scheduling information

• memory-management data

• accounting data

• I/O status

• Linux’s PCB is defined in struct task_struct: http://lxr.linux.no/linux+v3.2.35/

include/linux/sched.h#L

Process Control Block in Linux

  • (^) Represented by the C structure task_struct pid_t pid; /* process identifier / long state; / state of the process / unsigned int time_slice / scheduling information */ struct task struct parent; / this process’s parent / struct list head children; / this process’s children */ struct files struct files; / list of open files / struct mm_struct mm; / address space of this process/ …

Process Scheduling

  • (^) To maximize CPU utilization, kernel quickly switches processes onto CPU for time sharing
  • (^) Process scheduler selects among available processes for next execution on CPU
  • (^) Kernel maintains scheduling queues of processes:
    • (^) job queue : set of all processes in the system
    • (^) ready queue : set of all processes residing in main memory, ready and waiting to execute
    • (^) device queues : set of processes waiting for an I/O device
  • (^) Processes migrate among the various queues

Ready Queue And Device Queues

Schedulers

  • (^) Long-term scheduler (or job scheduler )
    • (^) selects which processes should be brought into the ready queue
    • (^) long-term scheduler is invoked very infrequently
      • (^) usually in seconds or minutes: it may be slow
    • (^) long-term scheduler controls the degree of multiprogramming
  • (^) Short-term scheduler (or CPU scheduler )
    • (^) selects which process should be executed next and allocates CPU
    • (^) short-term scheduler is invoked very frequently
      • (^) usually in milliseconds: it must be fast
    • (^) sometimes the only scheduler in a system
  • (^) Mid-term scheduler
    • (^) swap in/out partially executed process to relieve memory pressure

Scheduler

• Scheduler needs to balance the needs of:

• I/O-bound process

• spends more time doing I/O than computations

• many short CPU bursts

• CPU-bound process

• spends more time doing computations

• few very long CPU bursts

Context Switch

• Context switch : the kernel switches to another process for execution

• save the state of the old process

• load the saved state for the new process

• Context-switch is overhead ; CPU does no useful work while switching

• the more complex the OS and the PCB, longer the context switch

• Context-switch time depends on hardware support

• some hardware provides multiple sets of registers per CPU: multiple contexts

loaded at once

Process Creation

• Parent process creates children processes, which, in turn create other

processes, forming a tree of processes

• process identified and managed via a process identifier (pid)

• Design choices:

• three possible levels of resource sharing : all, subset, none

• parent and children’s address spaces

• child duplicates parent address space (e.g., Linux)

• child has a new program loaded into it (e.g., Windows)

• execution of parent and children

• parent and children execute concurrently

• parent waits until children terminate

Process Creation

• UNIX/Linux system calls for process creation

• fork creates a new process

• exec overwrites the process’ address space with a new program

• wait waits for the child(ren) to terminate