Process Is Not Same As Program!: Aup Notes 1 / 5
Process Is Not Same As Program!: Aup Notes 1 / 5
Jai Gajanan
TOPIC:
Typical arrangement of a user process (refer notes)
Process = text + data + stack
System call = by using it any active process obtain services from the kernel.
A system call is implemented in the kernel. When a program makes a system call, the
arguments are packaged up and handed to the kernel, which takes over execution of the program
until the call completes.
A system call isn’t an ordinary function call, and a special procedure is required to transfer
control to the kernel. Low-level I/O functions such as open and read are examples of system calls on
Unix/ Linux.
The system calls forms the most basic interface between programs and the kernel. Each call
presents a basic operation or capability.
To watch system call run command like
$strace hostname <enter>
Kernel = is OS, provides services such as file system, mem mgt, CPU scheduling, device
I/O for the programs
What is signal?
Informs the process occurrence of asynchronous event. It is also
called as “S/W interrupt”
Signal can be sent 1) By one process to another or 2) By kernel to
the process
Reading : What is signal? How and when are signals sent? ( page# 44)
i) Unix system calls for I/O : open, read, creat, write, close, lseek, dup, dup2… etc
Now what about dup and dup2 ? read from the book page# 41
Terminating a process
• exit (int status)
– Clean up the process (e.g close all files)
– Tell its parent processes that he is dying (SIGCHLD)
– Tell child processes that he is dying (SIGHUP)
– Exit status can be accessed by the parent process.
1. PIPES
• The oldest mechanism & common form of Unix IPC
• Half-duplex
• Can only be used between processes that have common ancestor
• Provides unidirectional communication ( one way )
• Is not associated with temporary file! ( pipe(pfd) )
FIFO’s
• Named pipes
• Allows only related processes to communicate
• Used by shell command to pass data from one shell pipeline to another without
creating intermediate temporary file
• Pass data between client and server process (mknode or mkfifo)
H/W
• What is the difference between open and dup?
A pipe is a communication device that permits unidirectional communication. Data written to the
“write end” of the pipe is read back from the “read end.” Pipes are serial devices; the data is always
read from the pipe in the same order it was written. Typically, a pipe is used to communicate
between two threads in a single process or between parent and child processes. In a shell, the
symbol “|” creates a pipe.
For example, this shell command see above BOX
A pipe’s data capacity is limited. If the writer process writes faster than the reader process
consumes the data, and if the pipe cannot store more data, the writer process blocks until more
capacity becomes available. If the reader tries to read but no data is available, it blocks until data
becomes available. Thus, the pipe automatically synchronizes the two processes.
2. Shared Memory:
• Fastest of all IPC mechanism
• Access to shared region of memory often controlled by semaphore
• Catch all for the shared memory operations…
• Slower than normal memory access
• Most useful of three structures
• Shared memory is accessible to many processes
• Quickest way to share information among processes
• Shared memory is persistence – we’ve to clean up (e.g. ipcrm command)
3. Semaphore:
• Main use to synchronize access to shared memory. (Dutch scientist “Dijkastra” P & V
operations)
• Is a counter to provide access to shared data for multiple processes.
[ -------------------------------------------------------- ]
[ learn about following command + options while learning IPC ]
[ $ipcs –m –q –s –a ]
[ $ipcrm –m ]
[ -------------------------------------------------------- ]
4. Messages:
Read from other notes/ book. It has no performance advantage
as compared to other techniques?
Learn about the typical movement of data between client and server using shared
memory. (refer fig 3.25/ p#154) and ( fig 3.24/ p#153)