23
Operating System Process & Scheduling [email protected]

01 Process and Scheduling

Embed Size (px)

DESCRIPTION

process and scheduling

Citation preview

  • Operating System

    Process & [email protected]

  • WHAT ?

    Process is a program in executionprocess execution must progress in sequential fashion

    a process includes:

    1. program counter

    2. stack

    3. data section

    Process in Memory

    2operating system process

  • Process State (important)

    As a process executes, it changes state

    New : The process is being created

    Running : Instructions are being executed

    Waiting : The process is waiting for some event to occur

    Ready : The process is waiting to be assigned to a processor

    Terminated : The process has finished execution

    3operating system - process

  • Diagram of Process State

    4operating system - process

  • Process Control Block (PCB)

    Information associated with each process

    Process state

    Program counter

    CPU registers

    CPU scheduling information

    Memory-management information

    Accounting information

    I/O status information

    Where is it ?

    5operating system - process

  • CPU Switch From Process to Process

    6operating system - process

  • Process Scheduling 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

    Processes migrate among the various queues

    7operating system - process

  • Representation of Process Scheduling

    8operating system - process

  • Schedulers

    Long-term scheduler (or job scheduler) selects which processes should be brought into the ready queue

    Short-term scheduler (or CPU scheduler) selects which process should be executed next and

    allocates CPU

    9operating system - process

  • Addition of Medium Term Scheduling

    10operating system - process

  • Context Switch (important)

    When CPU switches to another process, the system must save the state of the old process and load the saved

    state for the new process

    Context of a process represented in the PCB

    Context-switch time is overhead; the system does no useful work while switching

    Time dependent on hardware support

    11operating system - process

  • Process Creation

    Parent process create children processes, which, in turn create other processes, forming a tree of

    processes

    Process identified and managed by a processidentifier (pid)

    12operating system - process

  • Process Creation (cont)

    UNIX examples (UNIX ????)

    fork system call creates new process

    exec system call used after a fork to replace the process memory space with a new program

    13operating system - process

  • Process Termination

    Process executes last statement and asks the OS to delete it (exit)Output data from child to parent

    Process resources are deallocated by OS

    Parent may terminate execution of children processes (abort)Child has exceeded allocated resources

    Task assigned to child is no longer requiredparent is exiting

    Some operating system do not allow child to continue if its parent terminates

    All children terminated - cascading termination

    operating system - process 14

  • Interprocess Communication

    Processes may be independent or cooperating (Can affect or be affected by other processes, including

    sharing data)

    Why cooperating ?Information sharing , Computation speedup ,

    Modularity, and Convenience

    Two models of IPC :Shared memory & Message passing

    operating system - process 15

  • IPC modelWhich one is message passing ?

    Which one is Shared memory ?

    operating system - process 16

  • SCHEDULING

  • Dispatcher

    selects from among the processes in memory that are ready toexecute, and allocates the CPU to one of them

    decide when a process :1. running to waiting state2. running to ready state3. waiting to ready state4. Terminates

    Scheduling under 1 and 4 is nonpreemptive All other scheduling is preemptive

    operating system CPU Scheduling 18

  • Scheduling Factor1. CPU utilization - keep the CPU as busy as possible

    must be maximized2. Throughput - number of processes that complete their execution

    per time unit must be maximized

    3. Turnaround time - amount of time to execute a particular processmust be minimized

    4. Waiting time - amount of time a process has been waiting in the ready queuemust be minimized

    5. Response time - amount of time it takes from when a request was submitted until the first response is produced, not output (for timesharing environment)must be minimized

    operating system CPU Scheduling 19

  • SCHEDULING METHOD

    FIRST COME FIRST SERVE (FCFS / FIFO)

    SORTHEST JOB FIRST (SJF)

    PRIORITY BASED

    ROUND ROBIN

    operating system CPU Scheduling 20

  • References

    1. Abraham Silberschatz, Peter Baer Galvin, Greg Gagne, Operating System Concepts With Java,

    Wiley

    operating system - process 21

  • Assignment 2

    Make report about your experiment in dual boot

    Experiment 1 - Windows Linux

    1. Explain detail steps to install windows and then linux on the same machine/pc

    2. Explain about GRUB, or LILO according to the installation

    Experiment 2 Linux windows x

    1. Explain detail steps to install linux and then windows on the same machine/pc

    2. Is there any difference installation steps between 1st experiment and 2nd

    3. How about the GRUB or LILO, is it all right ? or anything is missing ? Explain how toovercome the missing thing (if there is something wrong)

    operating system - process 22

  • SUBMISSION

    Submit your report to elearning

    REPORT must contain :

    1. Cover page : Student id, and bla bla bla

    2. Explanation important step of those experiments

    3. References

    Format : AS2-.pdf (eg. AS2-5214100010.pdf)

    operating system - process 23