Documente Academic
Documente Profesional
Documente Cultură
Process Management I
Sohail Khan
sohail@unikl.edu.my
http://csrdu.org/sohail
Universiti Kuala Lumpur (UniKL)
Kuala Lumpur, Malaysia
INTRODUCTION
Process Concept
Process Scheduling
Operations on Processes
Process Management I
Sohail (http://csrdu.org/sohail)
2 / 26
PROCESS CONCEPTS
Process Management I
Sohail (http://csrdu.org/sohail)
3 / 26
PROCESS CONCEPTS
(COND.)
Process Management I
Sohail (http://csrdu.org/sohail)
4 / 26
PROCESS
A process includes:
registers...
stack temporary data (parameter, local variable...)
data section global variables, text section program code
may also include a heap memory that is dynamically allocated
during process runtime
Sohail (http://csrdu.org/sohail)
5 / 26
PROCESS
IN
MEMORY
Process Management I
Sohail (http://csrdu.org/sohail)
6 / 26
PROCESS STATE
waiting: The process is waiting for some event to occur (put in waiting
queues)
terminated: The process has finished execution
Process Management I
Sohail (http://csrdu.org/sohail)
7 / 26
PROCESS STATES
New
admitted
interrupt
Ready
exit
Terminated
Running
scheduler
dispatch
I/O or
event
completion
Process Management I
Waiting
I/O or
event
wait
Sohail (http://csrdu.org/sohail)
8 / 26
Process Management I
Sohail (http://csrdu.org/sohail)
9 / 26
Process Management I
Sohail (http://csrdu.org/sohail)
10 / 26
PROCESS SCHEDULING
The reset process will have to wait until the CPU is free and can be
rescheduled
Process Management I
Sohail (http://csrdu.org/sohail)
11 / 26
Process Management I
Sohail (http://csrdu.org/sohail)
12 / 26
Process Management I
Sohail (http://csrdu.org/sohail)
13 / 26
REPRESENTATION
Process Management I
OF
PROCESS SCHEDULING
Sohail (http://csrdu.org/sohail)
14 / 26
SCHEDULERS
Process Management I
Sohail (http://csrdu.org/sohail)
15 / 26
SCHEDULERS
(may be slow)
Process Management I
Sohail (http://csrdu.org/sohail)
16 / 26
ADDITION
OF
Process Management I
Sohail (http://csrdu.org/sohail)
17 / 26
Process Management I
TO
PROCESS
Sohail (http://csrdu.org/sohail)
18 / 26
CONTEXT SWITCH
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
via a context switch
perform a state save of the current state of the CPU
and then a state restore to resume operations
Process Management I
Sohail (http://csrdu.org/sohail)
19 / 26
OPERATIONS
ON
Resource sharing
Execution
Parent and children execute concurrently
Parent waits until children terminate
Process Management I
Sohail (http://csrdu.org/sohail)
20 / 26
OPERATIONS
(COND.)
Address space
ON
UNIX examples
Process Management I
Sohail (http://csrdu.org/sohail)
21 / 26
Process Management I
Sohail (http://csrdu.org/sohail)
22 / 26
int main() {
pid_t pid;
/* fork another process */
pid = fork();
if (pid < 0) { /* error occurred */
fprintf(stderr, "Fork Failed");
exit(-1);
}
else if (pid == 0) { /* child process */
execlp("/bin/ls", "ls", NULL);
}
else { /* parent process */
/* parent will wait for the child to complete */
wait (NULL);
printf ("Child Complete");
exit(0);
}
}
Process Management I
Sohail (http://csrdu.org/sohail)
23 / 26
Process Management I
SOLARIS
Sohail (http://csrdu.org/sohail)
24 / 26
OPERATIONS
ON
Process Management I
Sohail (http://csrdu.org/sohail)
25 / 26
End of Lecture 3
Process Management I
Sohail (http://csrdu.org/sohail)
26 / 26