Professional Documents
Culture Documents
Systems Programming: Assignment #1
Systems Programming: Assignment #1
Systems Programming: Assignment #1
Assignment #1
Q1: The exec family of functions provides a facility for overlaying the process image of the
calling process with a new image. In one or two sentences, please comment on the utility of
each of the following invariants of exec functions.
int execl(const char *path, const char *arg0, ... /*, char *(0) */);
int execle (const char *path, const char *arg0, ... /*, char *(0), char *const envp[] */);
int execlp (const char *file, const char *arg0, ... /*, char *(0) */);
int execv(const char *path, char *const argv[]);
int execve (const char *path, char *const argv[], char *const envp[]);
int execvp (const char *file, char *const argv[]);
#include <iostream>
#include <sys/types.h>
#include <unistd.h>
int main( ) {
fork( ); cout << "main " << endl;
fork( ); cout << "aisa " << endl;
fork( ); cout << "kio " << endl;
fork( ); cout << "ho " << endl;
return 0;
}
assuming all fork() system calls are successful, how many lines of output will be
produced? How many child processes are produced. Is it ever possible for a “aisa” to be output
before a “kio"? Why is this?
Q3: Write a program that produces five child processes. Submit evidence, via the
output of the ps or top command, that these processes are truly generated and are eventually
destroyed.
Q4: Write a C program that creates its child by fork() system call. The task of parent is to
print characters from A to Z, and the task of child is to print decimal numbers from 0 to 9. Write
this program using wait system call in such a way that results of parent and child could not be
jumble up.