3 Processes
3 Processes
https://www.youtube.com/watch?v=ss1-REMJ9GA
6:21
forked clones
https://www.youtube.com/watch?v=kDxjcyHu_Qs
Processes
To introduce the notion of a
process -- a program in
execution, which forms the basis
To explore interprocess
communication using shared
memory and message passing
To describe communication in
client-server systems
Process Concept
Bash is a
type of
Linux shell
(replaces
Bourne shell)
Kernel-
related
processe
s
tcsh is a
SSH stands for Secure SHell. It is a program designed type of
to allow users to log into another computer over a Linux
shell
network, to execute commands on that computer and to
move files to and from that computer. It effectively
replaces telnet, ftp and the rcp/rsh/remsh programs.
Process Creation
Resource sharing options
Parent and children share all available OS-
managed resources
Children share subset of parent’s resources
When a process creates a new process… .Either
the….
Parent and children execute concurrently
Parent waits until some or all children
terminate
Address space options
The child process is a duplicate of the parent
process (it has the same program and data as
the parent)
The child program has a new program loaded
Process Creation (Cont.)
UNIX examples
fork() system call creates new process
Returns PID to parent process
Returns 0 (zero) to child process
If the fork system call is successful, a child process is
produced that continues execution at the point where
it was called by the parent process.
After the fork system call, both the parent and child
processes are running and continue their execution
at the next statement in the parent process.
https://www.youtube.com/watch?v=ss1-REMJ9GA
Process Creation (Cont.)
UNIX examples
fork() system call creates new process
Returns PID to parent process
Returns 0 (zero) to child process
exec() system call used after a fork() to
replace the process’ memory space with a new
program optional
item buffer[BUFFER_SIZE];
int in = 0; in points to next free position
int out = 0; out points to first full position
Buffer – ; /* do nothing */
Producer buffer[in] = next_produced;
in = (in + 1) % BUFFER_SIZE;
}
item next_consumed;
while (true) {
while (in == out)
Bounded ; /* do nothing */
next_consumed = buffer[out];
Buffer – out = (out + 1) %
Consumer BUFFER_SIZE;
message next_produced;
while (true) {
/* produce an item in next produced */
send(next_produced);
}
message next_consumed;
while (true) {
receive(next_consumed);