Module 4: Processes - PowerPoint PPT Presentation

Loading...

PPT – Module 4: Processes PowerPoint presentation | free to view - id: 79921e-ZTg5N



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Module 4: Processes

Description:

Operating Systems Lecture 8 Processes II Read Ch. 4.3 - 4.5 – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 17
Provided by: Marily478
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Module 4: Processes


1
Operating Systems Lecture 8 Processes II Read
Ch. 4.3 - 4.5
2
Process Scheduling Queues
  • Recall the process migration through multiple
    queues
  • 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.

3
Ready Queue And Various I/O Device Queues
4
Representation of Process Scheduling
5
Schedulers
  • Long-term scheduler (or job scheduler)
  • selects which processes should be brought into
    the ready queue.
  • Is necessary when there are more processes
    submitted than can be stored in memory.
  • Absent or minimal on some systems (e.g. UNIX)
  • Short-term scheduler (or CPU scheduler)
  • selects which process should be executed next
    among processes in the ready queue.
  • Allocates the CPU to next process
  • Medium-term scheduler (swapper)
  • Temporarily removes process from memory and
    stores it on disk.
  • Later the process can be swapped back in.

6
Addition of Medium Term Scheduling
We will draw a new state diagram in class that
includes states for processes that have been
swapped out.
7
Questions about Swapping
Why are there two suspend states instead of
one? When the OS needs memory, what processes
get suspended? When memory becomes available,
which processes have highest priority to be
placed in the ready queue?
8
Frequency of Execution
  • Short-term scheduler is invoked very frequently
  • (milliseconds) ? (must be fast)
  • If it executes 1 time per 100 msec and takes 10
    msec to execute, what percentage of CPU time is
    used by the scheduler?
  • Long-term scheduler is invoked very infrequently
  • (seconds, minutes) ? (may be slow).
  • The long-term scheduler controls the degree of
    multiprogramming.
  • To keep the degree of multiprogramming stable,
    the scheduler must bring in new processes as old
    processes leave the system.
  • Medium term scheduler has an intermediate
    frequency of execution.

9
I/O bound vs. CPU bound
  • A process may be described as I/O bound or CPU
    bound.
  • I/O bound processes spend more time doing I/O
    than using the CPU.
  • CPU bound processes spend more time doing
    computation than using I/O
  • Process Mix
  • Ideally we want a good balance between CPU bound
    and I/O bound processes
  • What happens if all processes are I/O bound?
  • What happens if all processes are CPU bound?
  • Long term and medium term (swapper) schedulers
    can be used to maintain a good process mix.

10
Context Switch
  • When CPU switches to another process, the system
    must
  • save the state of the old process
  • load the saved state for the new process.
  • This is known as a context switch.
  • The context of a process is represented by the
    PCB.
  • Context-switch time is overhead the system does
    no useful work while switching.
  • The speed is dependent on hardware support, and
    may range between 1 and 1000 microseconds on
    different machines.
  • Example The SUN UltraSPARC has multiple sets of
    registers. To switch contexts, it just moves a
    pointer to a new register set.

11
Process Creation
  • Parent processes create children processes,
    which, in turn create other processes, forming a
    tree of processes.
  • UNIX processes
  • In UNIX, the swapper is the ancestor of all
    processes. PID 0 (process ID)
  • The first child of the swapper is the INIT
    process. PID 1
  • The INIT process is the parent process to all
    login processes.

12
Diagram of UNIX Process tree
We will diagram this in class.
13
Resources and Execution
  • Resource sharing
  • EITHER parent and children share all resources.
  • Children share subset of parents resources.
  • OR Parent and child share no resources.
  • Why is it a good idea to restrict the child to a
    subset of the parent's resources?
  • Execution
  • EITHER Parent and children execute concurrently.
  • OR Parent waits until some or all children
    terminate.

14
More on Child Processes
  • Address space
  • EITHER Child is a duplicate of the parent.
  • OR Child has a program loaded into it.
  • UNIX examples
  • fork system call creates new process (duplicate
    of parent).
  • exec system call used after a fork to replace the
    process memory space with a new program.
  • (we'll see how these work later).

15
Process Termination
  • Normal Termination
  • Process executes last statement and asks the
    operating system to delete it (exit).
  • Output data from child to parent (via wait).
  • Process resources are deallocated by operating
    system.

16
Other Modes of Termination
  • Other modes of termination
  • Parent may terminate execution of children
    processes (abort).
  • Child has exceeded allocated resources.
  • Task assigned to child is no longer required.
  • Parent is exiting.
  • Operating system may not allow child to continue
    if its parent terminates.
  • Cascading termination.
  • In UNIX--if the parent is terminated, the child
    is adopted by INIT.
About PowerShow.com