running
CPU utilization keep the CPU as busy as possible. Time quantum, q ; context switching,
c ;
Throughput # of processes that complete their execution per time unit
Turnaround time amount of time to execute a particular process
Waiting time amount of time a process has been waiting in the ready queue
Response time amount of time it takes from when a request was submitted until the first
response is produced, not output (for timesharing environment)
FCFS Easy to implement, not optimal
SJF Minimum delay
Priority Scheduling High priority first. Problem: starvation (low priority processes may never
execute). Solution: aging (increase process priority with time).
RR Each of the n processes gets small time quantum, q (usually 10-100 ms). No process
waits more than ( n1 ) q time units. If q is large, then RR is a FIFO. If q is small, then
context switching causes high overhead.
Pipes
#define READ_END 0
#define WRITE_END 1
#define BUFFER_SIZE 100
int fd[2];
char buffer[BUFFER_SIZE];
if(pipe(fd) == -1)
{
fprintf(stderr, "Pipe Failed.");
return 1;
}
if(fork())
{
close(fd[READ_END]);
write(fd[WRITE_END], buffer, BUFFER_SIZE);
close(fd[WRITE_END]);
}
else
{
close(fd[WRITE_END]);
read(fd[READ_END], buffer, BUFFER_SIZE);
close(fd[READ_END]);
}
Multithreads
Worse performance than single threads when I/O is needed or if tasks must be done sequentially.
Process
Burst
Time
Priority
Time
P
1
1
0
3
P
2
P
3
P
4
P
5
First-Come,
First-Served
Shortest Job
First
NonPreemptive
Priority
Round Robin
0
P
2
P1
P
2
P
4
P3
P
2
P
1
P
3
P3
P5
P
4
3
P
4
P1
P
5
P
1
P
3
P5
P1
P5
P
2
P
5
P
1
P
5
P
1
P3
P
5
P
1
P
5
P
4
P1