1. How do you execute one program from within another?
The system calls used for low-level process creation are execlp() and
execvp(). The execlp call overlays the existing program with the new one
, runs that and exits. The original program gets back control only when
an error occurs.
execlp(path,file_name,arguments..); //last argument must be NULL
A variant of execlp called execvp is used when the number of arguments is not known in advance.
execvp(path,argument_array); //argument array should be terminated by NULL
2. What is IPC? What are the various schemes available?
The term IPC (Inter-Process Communication) describes various ways by
which different process running on some operating system communicate
between each other. Various schemes available are as follows:
One-way communication scheme through which different process can
communicate. The problem is that the two processes should have a common
ancestor (parent-child relationship). However this problem was fixed
with the introduction of named-pipes (FIFO).
Message Queues :
Message queues can be used between related and unrelated processes running on a machine.
This is the fastest of all IPC schemes. The memory to be shared is
mapped into the address space of the processes (that are sharing). The
speed achieved is attributed to the fact that there is no kernel
involvement. But this scheme needs synchronization.
Various forms of synchronisation are mutexes, condition-variables, read-write locks, record-locks, and semaphores.
3. What is the difference between Swapping and Paging?
Whole process is moved from the swap device to the main memory for
execution. Process size must be less than or equal to the available main
memory. It is easier to implementation and overhead to the system.
Swapping systems does not handle the memory more flexibly as compared to
the paging systems.
Only the required memory pages are moved to main memory from the swap
device for execution. Process size does not matter. Gives the concept of
the virtual memory.
It provides greater flexibility in mapping the virtual address space
into the physical memory of the machine. Allows more number of processes
to fit in the main memory simultaneously. Allows the greater process
size than the available physical memory. Demand paging systems handle
the memory more flexibly.