cs211 lab1


http://maths.nuigalway.ie/~gettrick/teach/cs211/




  1. Type in mkdir cs211 to make a folder/directory where you will store your cs211 stuff.
  2. Type in cd cs211 to change directory.
  3. You may like to make further subdirectories/folders by typing mkdir labs or mkdir python etc.
  4. Familiarize yourself with the ps command, by typing ps to see what processes you are running, ps -aux to see all processes on the machine, man ps to see the manual/help pages for the ps command.
  5. TASK 1 Using the command ps -alx, find the process ID, and corresponding command, of three processes whose parent process is init() (whose process ID is 1). (Store that information in the comments (after the # tag) of one of your PYTHON files below, so the TA can see it when grading.)
  6. If you have a PYTHON program - lets say the file name is myfile.py - in your current directory (to see current directory, type pwd), then you can run the program by typing python3 myfile.py. Make yourself familiar with the programs orphanZombie.py and oZ2.py at https://maths.nuigalway.ie/~gettrick/teach/cs211/2026/progs/, and run them to see what they do.
  7. TASK 2 Write a PYTHON program where a parent process creates three child processes that then become orphan processes and live on for at least 20 seconds beyond the termination of the parent process.
  8. TASK 3 Write a PYTHON program where a parent process creates a child process (lets call this child process C), which then in turn creates two child processes of its own (denoted GC1 and GC2 - from the point of view of the original process, these are grandchildren). Thereafter in your code, make C turn in to an orphan process and both GC1 and GC2 turn in to zombie processes, for at least 10 seconds. (You should check your code works by using the top command to check for the two zombies.)
  9. TASK 4 Study the programs pipedemo.py and pipe3.py covered in lectures. Following this, write a PYTHON program with the following behaviour: A parent process creates two child processes; then the first child process reads in some text from the user, and sends it via a pipe to the second child process: thereafter the second child process reverses all the characters in the string and sends the reversed string back to the first child process (via a second pipe); finally the first child process prints the reversed string to the screen.


© University of Galway