Processor Management - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Processor Management

Description:

Priority Scheduling. Shortest Remaining Time (SRT) Round Robin. Multiple Level Queues ... FCFS Example. Process CPU Burst (Turnaround Time) A 15 milliseconds. B ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 26
Provided by: domi193
Category:

less

Transcript and Presenter's Notes

Title: Processor Management


1
????? 4
  • Processor Management
  • (single processor with single-threaded process)

2
???????????????? Single processing
  • ?? processor ????? (single core)
  • ?????????????????? (????????????????)
  • ??????????????????????????? (multitasking)
  • ?????? OS ???????????????? CPU ?????????
  • ???????????????????? ??????????????????
    ????????????????????????? ???????????????????
    ?????????????????????? ????????????????????????
    ??????????????????? ????????????????
  • ??????????????????
  • ????????????????????? CPU
  • ????????????????????????????????? memory

3
Process state(???????????? state
??????????????????????????????????
?.?.???????????????????????? ?????????????????????
??????????)
  • ?????????????????? process ???? process
    ??????????????????????? ??????????????????????????
    ??????? (???????????????????????????)
  • ????? process ???????????? ???????????????????????
    ???? ????? CPU ??????? (?????????????
    ??????????????????????? ?????? ... ???)
  • ????? process ????????????? (?????? CPU ????)
    ???????????????????????? (????? ... ???)
  • ??? process ???????? I/O ????????????????
    keyboard ???????????????????????
    ????????????????????? process ????????????????????
    ? CPU ?????????? ?????????????????? (????? ...
    ???)

4
Job and Process Status
Admitted
Finished
Interrupt
Exit
Scheduler dispatch
I/O or event completion
I/O or event wait
Handled by Process Scheduler Handled by Job
Scheduler
5
????? CPU ???? process ?????????????
  • ??????????????????????? ready ????????????????
    running
  • Process ?????????????? ready ?????????????????????
    ?????
  • Process ??????? ready ?????? process
    ?????????????? ?
  • ?????????????????? ready ?? 3 ????
    ????????????????????? 3 ???
  • ?????????????? ?????????????????? process
    ????????? CPU ???????
  • ??????????? process ??????????? ready ???????
    process ???????
  • ????????????????????????????????

6
????????????????? process ?????
  • ??? process ???????????????? CPU ??????????????
    CPU ??????????? process ??????????????????????????
    ????
  • ?????? process ??????????? CPU ?????????????
    ??????????????????? CPU ???? ?????? process
    ?????????????????????????????????????????
    ???????????????????????? ?????????????????????????
    ???????????????????? ?????????????????????????????
    ?? CPU ??????????????????
  • ??????????????????????????????????????????????????
    ??????????????
  • ??????????????????????????????? program counter,
    register content ???????? ??????????????? PCB
    ?????????????????????????????????? process
    ???????????????????
  • ???????????????????? Context Switching

7
Process Control Block (PCB)
  • Process Control Block (PCB) -- data structure
    that contains basic info about the job
  • Process identification
  • Process status (HOLD, READY, RUNNING, WAITING)
  • Process state (process status word, register
    contents, main memory info, resources, process
    priority)
  • Accounting (CPU time, total amount of time, I/O
    operations, number input records read, etc.)

8
PCBs and Queuing
  • PCB of job created when Job Scheduler accepts it
  • updated as job goes from beginning to
    termination.
  • Queues use PCBs to track jobs.
  • PCBs, not jobs, are linked to form queues.
  • E.g., PCBs for every ready job are linked on
    READY queue all PCBs for jobs just entering
    system are linked on HOLD queue.
  • Queues must be managed by process scheduling
    policies and algorithms.

9
Process Scheduling Algorithms
  • First Come First Served (FCFS)
  • Shortest Job Next (SJN)
  • Priority Scheduling
  • Shortest Remaining Time (SRT)
  • Round Robin
  • Multiple Level Queues

10
First Come First Served (FCFS)
  • Non-preemptive.
  • Handles jobs according to their arrival time --
    the earlier they arrive, the sooner theyre
    served.
  • Simple algorithm to implement -- uses a FIFO
    queue.
  • Good for batch systems not so good for
    interactive ones.
  • Turnaround time is unpredictable.

11
FCFS Example
  • Process CPU Burst (Turnaround Time)
  • A 15 milliseconds
  • B 2 milliseconds
  • C 1 millisecond
  • If they arrive in order of A, B, and C.
  • What does the time line look like?
  • Whats the average turnaround time?

12
Shortest Job Next (SJN)
  • Non-preemptive.
  • Handles jobs based on length of their CPU cycle
    time.
  • Use lengths to schedule process with shortest
    time.
  • Optimal gives minimum average waiting time for
    a given set of processes.
  • optimal only when all of jobs are available at
    same time and the CPU estimates are available and
    accurate.
  • Doesnt work in interactive systems because users
    dont estimate in advance CPU time required to
    run their jobs.

13
Priority Scheduling
  • Non-preemptive.
  • Gives preferential treatment to important jobs.
  • Programs with highest priority are processed
    first.
  • Arent interrupted until CPU cycles are completed
    or a natural wait occurs.
  • If 2 jobs with equal priority are in READY
    queue, processor is allocated to one that arrived
    first (first come first served within priority).
  • Many different methods of assigning priorities by
    system administrator or by Processor Manager.

14
Shortest Remaining Time (SRT)
  • Preemptive version of the SJN algorithm.
  • Processor allocated to job closest to completion.
  • This job can be preempted if a newer job in READY
    queue has a time to completion that's shorter.
  • Cant be implemented in interactive system --
    requires advance knowledge of CPU time required
    to finish each job.
  • SRT involves more overhead than SJN.
  • OS monitors CPU time for all jobs in READY queue
    and performs context switching.

15
Round Robin
  • Preemptive.
  • Used extensively in interactive systems because
    its easy to implement.
  • Isnt based on job characteristics but on a
    predetermined slice of time thats given to each
    job.
  • Ensures CPU is equally shared among all active
    processes and isnt monopolized by any one job.
  • Time slice is called a time quantum
  • size crucial to system performance (100 ms to 1-2
    secs)

16
If Jobs CPU Cycle lt Time Quantum
  • If jobs last CPU cycle job is finished, then
    all resources allocated to it are released
    completed job is returned to user.
  • If CPU cycle was interrupted by I/O request, then
    info about the job is saved in its PCB it is
    linked at end of the appropriate I/O queue.
  • Later, when I/O request has been satisfied, it is
    returned to end of READY queue to await
    allocation of CPU.

17
Time Slices Should Be ...
  • Long enough to allow 80 of CPU cycles to run to
    completion.
  • At least 100 times longer than time required to
    perform one context switch.
  • Flexible -- depends on the system.

18
Multiple Level Queues
  • Not a separate scheduling algorithm.
  • Works in conjunction with several other schemes
    where jobs can be grouped according to a common
    characteristic.
  • Examples
  • Priority-based system with different queues for
    each priority level.
  • Put all CPU-bound jobs in 1 queue and all
    I/O-bound jobs in another. Alternately select
    jobs from each queue to keep system balanced.
  • Put batch jobs background queue interactive
    jobs in a foreground queue treat foreground
    queue more favorably than background queue.

19
Policies To Service Multi-level Queues
  • No movement between queues.
  • Move jobs from queue to queue.
  • Move jobs from queue to queue and increasing time
    quantums for lower queues.
  • Give special treatment to jobs that have been in
    system for a long time (aging).

20
?????????? algorithm
  • ?????????????? algorithm ?????????????????????????
    ??? ?????????? process ????????????????????????
  • ?????????????????? algorithm ?? ?????? preemptive
    ???? non-preemptive ????????????????? time
    quantum ???????????????????????????????? OS
    ???????????????? OS ????????????
    ???????????????????????????????
  • CPU-bound jobs
  • I/O-bound jobs
  • Interactive jobs
  • Background jobs
  • Real time jobs
  • Transactions Processing jobs

21
Process Scheduling Policy
  • Maximize throughput by running as many jobs as
    possible in a given amount of time.
  • Maximize CPU efficiency by keeping CPU busy 100
    of time.
  • Ensure fairness for all jobs by giving everyone
    an equal amount of CPU and I/O time.
  • Minimize response time by quickly turning around
    interactive requests.
  • Minimize turnaround time by moving entire jobs
    in/out of system quickly.
  • Minimize waiting time by moving jobs out of READY
    queue as quickly as possible.

22
Interrupts
  • There are instances when a job claims CPU for a
    very long time before issuing an I/O request.
  • builds up READY queue empties I/O queues.
  • Creates an unacceptable imbalance in the system.
  • Process Scheduler uses a timing mechanism to
    periodically interrupts running processes when a
    predetermined slice of time has expired.
  • suspends all activity on the currently running
    job and reschedules it into the READY queue.

23
Cache Memory
  • Cache memory -- quickly accessible memory thats
    designed to alleviate speed differences between a
    very fast CPU and slower main memory.
  • Stores copy of frequently used data in an easily
    accessible memory area instead of main memory.

24
Types of Interrupts
  • Page interrupts to accommodate job requests.
  • Time quantum expiration.
  • I/O interrupts when issue READ or WRITE command.
  • Internal interrupts (synchronous interrupts)
    result from arithmetic operation or job
    instruction currently being processed.
  • Illegal arithmetic operations (e.g., divide by
    0).
  • Illegal job instructions (e.g., attempts to
    access protected storage locations).

25
Interrupt Handler
  • Describe store type of interrupt (passed to
    user as error message).
  • Save state of interrupted process (value of
    program counter, mode specification, and
    contents of all registers).
  • Process the interrupt
  • Send error message state of interrupted process
    to user.
  • Halt program execution
  • Release any resources allocated to job are
    released
  • Job exits the system.
  • Processor resumes normal operation.
Write a Comment
User Comments (0)
About PowerShow.com