process management
Download
Skip this Video
Download Presentation
Process Management

Loading in 2 Seconds...

play fullscreen
1 / 39

Process Management - PowerPoint PPT Presentation


  • 73 Views
  • Uploaded on

Process Management. Operating Systems Lecture 3 , 2 7 March 2003 Mr. Greg Vogl Uganda Martyrs University. Overview. Monolithic kernel vs. microkernel (lecture 1) Program, Process, Thread Interrupts Process States Process Scheduling Processes in UNIX Processes in Windows.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Process Management' - devika


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
process management

Process Management

Operating Systems

Lecture 3, 27 March 2003

Mr. Greg Vogl

Uganda Martyrs University

overview
Overview
  • Monolithic kernel vs. microkernel (lecture 1)
  • Program, Process, Thread
  • Interrupts
  • Process States
  • Process Scheduling
  • Processes in UNIX
  • Processes in Windows

Operating Systems: Process Management

1 monolithic kernel
1. Monolithic Kernel

Operating Systems: Process Management

microkernel
Microkernel

Operating Systems: Process Management

2 program
2. Program
  • Series of commands
  • Instructions only (usually not data)
  • Stored on disk, copied into memory
  • Can be in use by many users and processes at the same time
  • Also called software
    • Includes shell scripts, batch files

Operating Systems: Process Management

process
Process
  • Variables point to instructions + data
  • Loaded in memory
    • context contains all process state info.
    • stored in Process Control Block
  • One user and one program per process
  • Also called task
    • (or job for batch processes)

Operating Systems: Process Management

process context
Process Context
  • program counter
    • register indicating next program instruction to run
  • other registers
    • accumulator, index/address, status, general
  • stack of subroutine return addresses
    • subroutines call other subroutines
  • values of local and global variables
    • pointers to open data files
  • user and terminal number (in multi-user OS)

Operating Systems: Process Management

examples of processes
Examples of Processes
  • User Processes
    • Shells
    • Text editors, databases
    • Background jobs (end with & in UNIX)
  • System Processes
    • Memory management, process scheduling
    • daemons (system background processes)
      • Mail and print servers

Operating Systems: Process Management

thread
Thread
  • Also called sub- or lightweight process
  • Little private memory; memory is shared
  • Subdivides work of the process
  • Threads are managed by the process
  • Reduces high overhead for creating processes and context switching
  • Java was designed to write thread-based programs

Operating Systems: Process Management

thread components
Thread Components
  • At minimum, every thread has its own
    • program counter
    • stack
  • Program text shared with other threads
  • Each procedure has a frame to hold its local variables
  • Heap of objects is shared by all threads

Operating Systems: Process Management

uses of threads
Uses of Threads
  • Servers (database, mail, print, etc.)
    • one thread per client request
  • Network server
    • one thread per connection
  • Time-sharing
    • one thread per user
  • Real-time factory control
    • one thread per device

Operating Systems: Process Management

3 interrupt
3. Interrupt
  • Signal hardwareCPU requesting services
    • CPU postpones its work to handle interrupt
  • Interrupt handler routines are part of OS code
    • OS switches modes (usersupervisor)
  • Interrupts are prioritised
    • Stack used to store multiple interrupt levels
  • Programs can mask (ignore) some interrupts
    • Others unmaskable (to avoid losing data)

Operating Systems: Process Management

examples of interrupts
Examples of Interrupts
  • Key pressed
  • Disk or other I/O task finished
  • System clock

Operating Systems: Process Management

software interrupts
Software Interrupts
  • Also called traps or exceptions
  • Processor interrupted by programs
  • Examples
    • Division by 0 error
    • Bus error
    • Array out of bounds
    • Buffer overflow

Operating Systems: Process Management

context switching
Context Switching
  • Preserve state of current process
  • Start or re-start another process
  • Performed by dispatcher (OS component)
  • When to change context?
    • Overhead cost (takes CPU time)
    • Processes prioritised by properties

Operating Systems: Process Management

4 process states
4. Process States
  • Runnable
    • Running (only one per processor)
    • Ready (waiting for its turn to run)
  • Blocked
    • Explicit e.g. wait() until a child terminates
    • Implicit e.g. read()
    • Blocked by another process
  • New (not yet allowed to wait its turn)
  • Suspended (e.g. swapped to virtual memory)
  • Terminated (finished but still using resources)

Operating Systems: Process Management

process state diagram ritchie p 62
Process State DiagramRitchie p. 62

entry (HLS)

I/O completion

ready

blocked

(LLS)dispatch

timeout

I/O wait

(MLS)suspend

running

resume

suspend

resume

suspend

termination

blocked suspended

ready suspended

I/O completion

Operating Systems: Process Management

5 scheduling
5. Scheduling
  • Assign each process time to use CPU
    • Determine sequence (order), timing (when)
    • Conflicting objectives  need compromise
  • Scheduling levels
    • High: whether to admit a new process
    • Medium: suspend/resume a process
    • Low: dispatch (run) a ready process

Operating Systems: Process Management

scheduling objectives
Scheduling Objectives
  • Maximise throughput
  • Give all users a “fair” (not equal) chance
  • Provide tolerable performance
    • Response time for on-line user
    • Turnaround time for batch users
  • Degrade performance gracefully
    • OK to be slow but avoid complete collapse
  • Be consistent, predictable over time

Operating Systems: Process Management

scheduling criteria
Scheduling Criteria
  • Priority which may be either/both:
    • Assigned to job by user
    • Determined by properties of the job
  • Class of job (real-time > on-line > batch)
  • Resources needed (CPU time, memory)
  • I/O or CPU bound (the aim is a balance)
  • Resources already used
  • Time already waited

Operating Systems: Process Management

types of scheduling policies
Types of Scheduling Policies
  • Preemptive (Used by most OS today)
    • OS stops one process to run another
  • Non-preemptive
    • process runs until termination or I/O wait
  • Cooperative (Used by Windows 3.11)
    • Programs must voluntarily give up CPU
    • Not managed by OS; trusts programmers
    • If a process hangs the whole PC hangs 

Operating Systems: Process Management

scheduling policies
Scheduling Policies
  • First come first served (FCFS/FIFO)
  • Shortest job first (SJF)
  • Shortest remaining time (SRT)
  • Highest response ratio next
  • Round robin (RR)
  • Multi-level feedback queues (MFQ)

Operating Systems: Process Management

first come first served
First come first served
  • Also called first in first out (FIFO)
  • Process waiting longest is first in queue
  • Favours long jobs
    • high run-time/wait-time ratio
  • Favours CPU-bound jobs
    • I/O devices underused

Operating Systems: Process Management

shortest job first next
Shortest job first (next)
  • Run job with shortest estimated run time
  • Long jobs may be delayed indefinitely
  • JCL commands can specify run time

Operating Systems: Process Management

shortest remaining time
Shortest remaining time
  • Run job w/ shortest est. remaining time
  • Highly favours short jobs
  • Long jobs will be delayed indefinitely
  • Requires estimating total run time
  • Requires measuring elapsed run time

Operating Systems: Process Management

highest response ratio next
Highest response ratio next
  • P = (time waiting + run time) / run time
  • Priority based on two factors
  • Favours shorter jobs
  • Guarantees a job cannot be starved

Operating Systems: Process Management

round robin
Round Robin
  • Each process given a set time slice
  • Pre-emption at end of time quantum
    • Hardware timer generates interrupts
  • After running, go to back of queue
  • Used in most interactive operating systems
  • How large should each time slice be?
    • Small  high context switch overhead
    • Large  user response time is reduced
    • In practice, about 10-20 ms

Operating Systems: Process Management

multi level feedback queues
Multi-level feedback queues
  • Separate queues for different priorities
    • New process  level 1 FIFO (highest)
    • After timeout  level 2 FIFO, etc.
    • Lowest level is Round Robin
  • Adapts to past process behaviours
    • high CPU usage  reduced access level
  • Long processes may starve
    • if wait time is long, promote/increase slice

Operating Systems: Process Management

6 unix process creation
6. UNIX process creation
  • PID 0: sched (process scheduler)
  • PID 1: init (ancestor of other processes)
  • daemons (automatic, for sys. admin.)
  • getty (one per terminal)
  • login (lets users log in)
  • shell (lets users run programs)
  • user-initiated processes (run from shell)

Operating Systems: Process Management

unix fork
UNIX fork()
  • fork() produces new “child” process
  • Child is exact copy of parent
    • Starts in same program, at same place
    • Exact copy of memory space
      • (globals, stack, heap object)
  • Both calls to fork() return a value
    • Parent fork() returns process ID of child
    • Child fork() returns 0

Operating Systems: Process Management

unix exec
UNIX exec()
  • Execute (load, run) another program
  • Overwrite calling process in memory
  • Uses same PID; not a new process
  • Used after fork() to start new process
  • Parent waits for child process to finish
  • Run in background to not hold up shell
    • myprogram &

Operating Systems: Process Management

unix scheduling
UNIX scheduling
  • Varies with the flavour of UNIX
    • Often dynamic priority, round robin, MFQ
  • Processes have number priority values
    • 0=highest, 60=lowest, 20=initial/default
  • Users can reduce priority using nice
    • nice -10 myprog # makes priority 30
  • Only superuser can increase priority
    • nice --10 myprog # makes priority 10

Operating Systems: Process Management

unix ps
UNIX ps
  • Command to display process status
  • ps # list PIDs, TTYs, CPU time, name
  • ps -a # all terminal-created processes
  • ps -e # everything (incl. daemons)
  • ps -f # full list (more details)
  • ps -l # long list (ppid, priority, size, nice)

Operating Systems: Process Management

other unix commands
Other UNIX commands
  • top – process list, continuously updated
  • jobs – list jobs running in current shell
  • bg, fg – send jobs to back/foreground
  • at – run batch job at specified time(s)
  • kill – send signal to terminate process
  • sleep – pause for some seconds

Operating Systems: Process Management

7 processes in windows
7. Processes in Windows
  • Every process treated as thread
  • Process can create additional threads
  • Scheduler operates over all threads
  • Each process has virtual address space
  • No parent-child process relationship
  • Environment copied to new processes

Operating Systems: Process Management

dynamic link libraries dlls
Dynamic Link Libraries (DLLs)
  • Executable code routines
  • Linked into application only at run time
  • Can be shared by several programs

Operating Systems: Process Management

starting programs
Starting Programs
  • Type program name (maybe full path)
    • MS-DOS prompt, run dialog box, Explorer
  • Double-click icon
    • Desktop, Explorer, My Computer
  • Click shortcut
    • Start or Programs menu, QuickLaunch
  • Start when the computer starts
    • autoexec.bat, config.sys, Startup menu

Operating Systems: Process Management

managing tasks
Managing Tasks
  • Ways to close programs
    • Ctrl-C; File, Exit; Close button (X); Alt-F4
  • Press Ctrl-Alt-Del to view task manager
    • End Task: stop non-responding program
    • Ctrl-Alt-Del again to shut down/restart

Operating Systems: Process Management

winme system information
WinMe System Information
  • Loaded modules (exe, dll, etc.)
    • Name, version, size, file date, mfg., path
  • Running tasks
    • Name, path, PID, priority, version, size
  • Startup programs
    • Program, command, user name, location
  • Print jobs

Operating Systems: Process Management

ad