Linux Process Concurrency and Synchronization
Objectives:
Design and develop systems programs using C/C++
Effectively use Linux system calls for process control and management, especially, fork, exec, wait, pipe and kill system call API.
Concurrent execution of processes.
Solve inter-process communication problems during concurrent execution of processes.
Use semaphores.
Problem Statement:
This project is to be developed in several small steps to help you understand the concepts better.
1. Write a C program, deploy the signal. Let the program print “sleep\n” per second. When the progress receive the SIGINT signal, it start to print “hello\n” every two seconds, while it still print “sleep\n” at the original frequency. The progress will exit after a certain time, e.g. 10s. (Sig.c → Sig)
2. Write a C program that makes a new copy of an existing file using system calls for file manipulation, such as open, read, write. The names of the two files, source and the destination are to be specified as command line arguments. Open the source file in read only mode and destination file in read/write mode. While the main function will carry out file opening and closing, a separate copy function needs to be written to do the actual copying. Copying can be done in blocks of suitable size. (MyCopy.c →MyCopy)
An optional usage can be:
>>./MyCopy srcFile desFile
3. Write a C program that forks two processes one for reading from a file (source file) and the other for writing (destination file) into. These two programs communicate using exec system call. Once again the program accomplishes copying files, the names of which are specified as command-line arguments. (ForkCopy.c → ForkCopy)
4. Write a C program that forks two processes one for reading from a file (source file) and the ather for writing (destination file) into. These two programs communicate using pipe system call. Once again the program accomplishes copying files, the names of which are specified as command-line arguments. (PipeCopy.c → PipeCopy)
5. Write a C program that forks two processes one for reading from a file (source file) and the other for writing (destination file) into. These two programs communicate using Socket. Once again the program accomplishes copying files, the names of which are specified as command-line arguments. (SockCopy.c → SockCopy)
6. Write a shell-like program that illustrates how Linux spawns processes. This simple program will
provide its own prompt to the user, read the command from the input and execute the command. It is sufficient to handle just “argument-less” commands, such as ls and date. (MyShell.c →MyShell)
7. Make the mini-shell (from the previous part) a little more powerful by allowing arguments to the commands. For example, it should be able to execute commands such as more filename and ls –l ~/tmp etc. (MoreShell.c →MoreShell)
8. Add to the mini-shell ability to execute command lines with commands