Understanding Process Scheduling (UPS)


UPS:   SOLD       




Substance Process Scheduling

  1. Scheduling
  2. Scheduling Tasks
  3. Scheduling Objectives and Criteria
  4. Scheduling Type
  5. Scheduling Techniques / Strategies
  6. Types of Scheduling Algorithms

1. Scheduling

Is a group of wisdom and mechanisms in the operating system related to the sequence of work performed by the computer system.

2. Scheduling Tasks

  • To decide which process should run
  • To decide when and how long the process will run.

3. Scheduling Objectives and Criteria

  • Fairness, namely that each process receives fair service from the processor.
  • Efficiency in CPU/processor usage, namely keeping the processor busy so that efficiency reaches maximum.
  • Response time can be minimized, namely the time required by a process from requesting service until there is a first response that responds to the request.
  • Waiting time can be minimized, namely the time required by a process to wait in the queue.
  • Turn around time can be minimized, namely the time required from when the program/process starts entering the system until the process is completed by the system.

Turn around time = execution time + waiting time

Throughput/breakthrough can be maximized, namely the amount/quantity of work that can be completed in one unit of time.

4. Scheduling Type

There are three types of Schedulers, namely:

a. Short term scheduler

  • Responsible for scheduling processor allocation among ready processes in main memory.
  • The goal is to maximize performance to meet the expected criteria.

b. Medium term scheduler

  • To handle swapping processes, processes that have a small critical condition, then at that time as a pending process, once the condition that caused it to be pending is gone, the process is put back into main memory and ready.
  • Swapping is the activity of moving pending processes from main memory to secondary memory.

c. Long term scheduler

Works against a batch queue and selects the next batch to be executed. Batches are usually power intensive processes (cpu time, memory, I/O devices)

5. Scheduling Techniques/Strategies

  • Scheduling without priority, that is, a process is given a processing time quota according to the order in which it enters the queue.
  • Scheduling with priority, namely a process gets first priority to obtain processing time/processing services.
  • Nonpreemptive scheduling, that is, once a process obtains processing time, the processing cannot be taken over by another process until that process is finished.
  • Preemptive scheduling, that is, when a process obtains processing time, the processor can be taken over by another process so that the process is interrupted before it is finished and must be continued waiting for the processing time quota to arrive again for that process.

Discussion of Process Scheduling Issues

Question 1

| Nama proses | Saat Tiba | Burst Time |
|-------------|-----------|------------|
| P1          | 0         | 14         |
| P2          | 0         | 10         |
| P3          | 2         | 13         |
| P4          | 3         | 8          |
| P5          | 5         | 3          |

Using the First come, first served (fcfs) or First In, First Out (FIFO) and Shorted Job First Scheduler (SJF) algorithms, find:

  • Average waiting time 
  • Average response time 
  • Turn arround time

Answer 1

| Nama Proses | Saat Tiba | Burst Time | Saat Mulai | Saat selesai | Waktu Tunggu | Waktu Tanggap |
|-------------|-----------|------------|------------|--------------|--------------|---------------|
| P1          | 0         | 14         | 34         | 48           |              |               |
| P2          | 0         | 10         | 0          | 10           |              |               |
| P3          | 0         | 13         | 21         | 34           |              |               |
| P4          | 0         | 8          | 13         | 21           |              |               |
| P5          | 0         | 3          | 10         | 13           |              |               |

Penalty Ratio Example

| Nama proses | Saat Tiba | Burst Time |
|-------------|-----------|------------|
| P1          | 0         | 6          |
| P2          | 1         | 2          |
| P3          | 1         | 3          |
| P4          | 2         | 4          |
| P5          | 3         | 1          |

Gantt Chart

a. Average waiting time

| Nama proses | Saat Tiba | Burst Time | Waktu tunggu | Ratio             |
|-------------|-----------|------------|--------------|-------------------|
| P2          | 1         | 2          | 5            | (5+2)/2 =7/2 =3,5 |
| P3          | 1         | 3          | 5            | (5+3)/3=8/3=2,66  |
| P4          | 2         | 4          | 4            | (4+4)/4= 2        |
| P5          | 3         | 1          | 3            | (3+1)/1 = 4       |

What is being worked on is P5

b. Average response time

| Nama proses | Saat Tiba | Burst Time | Waktu tunggu | Ratio           |
|-------------|-----------|------------|--------------|-----------------|
| P2          | 1         | 2          | 6            | (6+2)/2 =8/2 =4 |
| P3          | 1         | 3          | 6            | (6+3)/3=9/3=3   |
| P4          | 2         | 4          | 5            | (5+4)/4= 2,     |

What is being worked on is P2

c. Turn arround time

| Nama proses | Saat Tiba | Burst Time | Waktu tunggu | Ratio               |
|-------------|-----------|------------|--------------|---------------------|
| P3          | 1         | 3          | 8            | (8+3)/3=11/3=3,66   |
| P4          | 2         | 4          | 7            | (7+4)/4= 11/4 =2,75 |

What is being worked on is P3

Table Process

| Nama Proses | Saat Tiba | Burst Time | Saat Mulai | Saat selesai | Waktu Tunggu | Waktu Tanggap |
|-------------|-----------|------------|------------|--------------|--------------|---------------|
| P1          | 0         | 6          | 0          | 6            | 0            | 6             |
| P2          | 1         | 2          | 7          | 9            | 6            | 2             |
| P3          | 1         | 3          | 9          | 12           | 8            | 3             |
| P4          | 2         | 4          | 12         | 16           | 10           | 4             |
| P5          | 3         | 1          | 6          | 7            | 3            | 1             |

Alternative Scheduling Example Questions

1. First Come First Serve (FCFS)

This process is also called FIFO (First In First Out), where the process that arrives first will be executed first.

The advantages of this process are:

  1. It is the simplest scheduling method
  2. Little overhead
  3. Can prevent starvation.

Disadvantages:

Short processes can be disadvantaged, if their execution sequence is after a long process.

Example:

There are 5 processes that will be executed using the FCFS scheduling algorithm. The arrival time and service time for each process are as shown in the table below.

| Proses | Arival Time | Service Time |
|--------|-------------|--------------|
| A      | 0           | 3            |
| B      | 2           | 6            |
| C      | 4           | 4            |
| D      | 6           | 5            |
| E      | 8           | 2            |

Describe the execution sequence that occurs and calculate the finish time, TAT (Turn Around Time), and NTAT (Normalized Turn Around Time) for each process!

Solution:

Gantt Chart

Table Process

| Process      | A    | B    | C    | D    | E    | Mean |
|--------------|------|------|------|------|------|------|
| Finsih Time  | 3    | 9    | 13   | 18   | 20   |      |
| Arival Time  | 0    | 2    | 4    | 6    | 8    |      |
| TAT          | 3    | 7    | 9    | 12   | 12   | 8.60 |
| Service Time | 3    | 6    | 4    | 5    | 2    |      |
| NTAT         | 1.00 | 1.17 | 2.25 | 2.40 | 6.00 | 2.56 |

2. Round-Robin (RR)

Process execution is carried out based on a certain time allocation which is regulated by a clock interrupt.

Advantages:

  • Can avoid unfair service to small processes as has happened in FCFS.
  • Faster response time for small sized processes
  • Can prevent starvation
  • Small overhead, if the average process size is smaller than the quantum / slot.

Disadvantages:

  • Performance is worse than FCFS if the slot size is larger than the largest process size.
  • Excessive overhead can occur if the size of each slot is too small.
  • I/O bound processes get less service.

Example:

Here is a case like in FCFS, but solved by Round-Robin method with quantum = 1

Gantt Chart

Table Process

| Process      | A    | B    | C    | D    | E    | Mean  |
|--------------|------|------|------|------|------|-------|
| Finsih Time  | 4    | 18   | 17   | 20   | 15   |       |
| Arival Time  | 0    | 2    | 4    | 6    | 8    |       |
| TAT          | 4    | 16   | 13   | 14   | 7    | 10.80 |
| Service Time | 3    | 6    | 4    | 5    | 2    |       |
| NTAT         | 1.33 | 2.67 | 3.25 | 2.80 | 3.50 | 2.71  |

3. Shortest Process Next (SPN)

Process execution is arranged based on the estimated size of the smallest process. So the process that comes later will be placed in front and executed first if the size of the process is the smallest among the other processes.

Advantages:

  • Can prevent small process losses as experienced by FCFS
  • High throughput
  • A small process has a small response time.

Disadvantages:

  • The scheduler must know or estimate the size of each process to be executed.
  • Large processes can experience starvation
  • Overhead can be high

Example:

As in the case of FCFS which is solved using the SPN method.

Gantt Chart

Table Process

| Process      | A    | B    | C    | D    | E    | Mean |
|--------------|------|------|------|------|------|------|
| Finsih Time  | 3    | 9    | 15   | 20   | 11   |      |
| Arival Time  | 0    | 2    | 4    | 6    | 8    |      |
| TAT          | 3    | 7    | 11   | 14   | 3    | 7.60 |
| Service Time | 3    | 6    | 4    | 5    | 2    |      |
| NTAT         | 1.00 | 1.17 | 2.75 | 2.80 | 1.50 | 1.84 |

4. Shortest Remaining Time

Process execution is arranged based on the smallest estimated remaining time, incoming processes can be executed directly if their total execution time is smaller than the remaining time of the running process.

Advantages:

  • The average quality of service received by processes is better (the number of processes that obtain an NTAT = 1 score is greater)
  • High throughput
  • Fast response time.

Disadvantages:

  • There is overhead because the scheduler has to calculate/estimate the remaining execution time of each process to determine the smallest remaining time.
  • Starvation may occur in long processes.
  • A long process is defeated by a small process

Example:

Solution to problems such as FCFS using the SRT method.

Gantt Chart

Table Process

| Process      | A    | B    | C    | D    | E    | Mean |
|--------------|------|------|------|------|------|------|
| Finsih Time  | 3    | 15   | 8    | 20   | 10   |      |
| Arival Time  | 0    | 2    | 4    | 6    | 8    |      |
| TAT          | 3    | 13   | 4    | 14   | 2    | 7.20 |
| Service Time | 3    | 6    | 4    | 5    | 2    |      |
| NTAT         | 1.00 | 2.17 | 1.00 | 2.80 | 1.00 | 1.59 |

5. Highest Response Ratio Next (HRRN)

Process selection is based on the highest response ratio. The response ratio is obtained from the comparison of the total waiting time (w) plus the estimated service time (s) with the estimated service time (s).

R = w+s / s

Profit:

  • Can prevent starvation
  • Each process will get balanced process service
  • Fast response time
  • High throughput.

Disadvantages:

Overhead occurs because the scheduler must know the service time of the processes to be executed.

Example:

Solution to solve cases like in FCFS but using HRRN

Gantt Chart

Table Process

| Process      | A    | B    | C    | D    | E    | Mean |
|--------------|------|------|------|------|------|------|
| Finsih Time  | 3    | 9    | 13   | 20   | 15   |      |
| Arival Time  | 0    | 2    | 4    | 6    | 8    |      |
| TAT          | 3    | 7    | 9    | 14   | 7    | 8.00 |
| Service Time | 3    | 6    | 4    | 5    | 2    |      |
| NTAT         | 1.00 | 1.17 | 2.25 | 2.80 | 3.50 | 2.18 |

6. Feedback

Each incoming process is immediately entered into the highest priority queue, so that it is immediately executed for one slot or one quantum. If the process is preempted by another process or its time quota runs out, it is then put into a lower priority queue (this technique is called multilevel feedback).

Advantages:

Can be used in conditions where information about the process length or estimated execution time is unknown.

Disadvantages:

  • Turn around time (TAT) of a long process can become even longer
  • A long process can experience starvation if new processes continuously arrive.
  • High overhead

Example:

Gantt Chart

Table Process

| Process      | A    | B    | C    | D    | E    | Mean  |
|--------------|------|------|------|------|------|-------|
| Finsih Time  | 4    | 20   | 16   | 19   | 11   |       |
| Arival Time  | 0    | 2    | 4    | 6    | 8    |       |
| TAT          | 4    | 18   | 12   | 13   | 3    | 10.00 |
| Service Time | 3    | 6    | 4    | 5    | 2    |       |
| NTAT         | 1.33 | 3.00 | 3.00 | 2.60 | 1.50 | 2.29  |
 

Priority Scheduling Concept Using Linux Terminal


Assignment 3 - OPERATING SYSTEMS PRACTICE - Priority Scheduling

  1. Login as root
  2. Open 3 terminals, display on the same screen
  3. In each terminal, type PS1="\w:" followed by Enter. \w displays the path to the home directory.
  4. Since you are logged in as root, ~: will be displayed on every terminal. For each terminal, type pwd and press Enter to see that you are in the /root directory.
  5. Open the terminal again (fourth), adjust the position so that all four terminals are visible on the screen.
  6. In the fourth terminal, type top and press Enter. Then the top program will appear. Type i. Top will display the active processes. Type lmt. Top will no longer display information at the top of the screen. In this experiment, the fourth terminal is the Top window.
  7. In terminal 1, open the C++ executable program by typing the yes program and pressing Enter.
  8. Repeat step 7 for terminal 2
  9. The Top window will display two yes programs as running processes. The %CPU value is the same for both. This means that both processes consume the same processing time and run equally fast. The PID of both processes will be different, for example 7225 and 7251. Then use terminal 3 (which does not run primes or the Top window) and type renice 19 (example: renice 19 7225) followed by Enter. This means changing the priority scheduling of the process to 19
  10. Wait a few moments until the top program changes and is visible in the Top window. The STAT column shows N for process 7225. This means that the priority scheduling for process 7225 is greater (slower) than 0. Process 7251 runs faster11. The top program also has the same function as the renice program. Select the Top Window and press r. Then the top program will display the PID to renice prompt: press 7225 (remember that you must replace 7225 with your own PID) and press Enter. Then the top program will display the Renice PID 7225 to value prompt: press -19 and press Enter.
  11. PID to renice: 7225
  12. Renice PID 7225 to value: -19
  13. In the above experiment, wait a few moments for the top to change and look at the %CPU values ​​on both processes. Now process 7225 is faster than process 7251. The status column shows < on process 7225 which indicates lower priority scheduling (faster) than the value 0.
  14. Select terminal 3 (which is not running yes or the top program) and type nice --n -10 yes and press Enter. Wait a few moments for the top program to change and the third primes process will be visible. For example, its PID is 4107. The -10 option is in the NI column (priority scheduling).
  15. Then do not use the mouse and keyboard for 10 seconds. The top program displays active processes other than the yes program. Then the top process will be listed but the % CPU is small (under 1.0) and consistent. Also visible processes related to the graphical desktop such as X, panels etc.
  16. The results are as below:
  17. Move the mouse so that the cursor changes to the screen and see what happens to the top display. Additional processes will appear and the %CPU value will change as the graphical part works. One reason is that process 7474 is running on a high priority scheduler. Select the Top window, type r. This will bring up the PID to renice prompt: Type 7474 (replace 7474 with your PID) and press Enter. This will bring up the Renice PID 7474 to value prompt: type 0 and press Enter. Now move the mouse around the screen. See the changes.
  18. Close all terminal windows
  19. Logout and log back in as user.

Information:

  • PS : by default to display information about all running processes.
  • PID: process identifier or called process ID, which is a number used by most operating system kernels.

Solution:

OPEN / DOWNLOAD File

Reference:


Post a Comment

Previous Next

نموذج الاتصال