cs211 lab1


http://www.maths.nuigalway.ie/~gettrick/teach/cs211/labs/l1.html




  1. Log on to your computer/PC in the normal way. Look for the red ICON with the label/name NX Client or No Machine. Open this software, and connect to leas.nuigalway.ie. (LEAS is the main Linux machine on campus, "Linux Environment for Academic Studies.) Log on to this machine using your normal username and password.
  2. When you have logged on, there is an icon in the window called Terminal, click on that to open a command line terminal.
  3. Repeat the last step (to open another terminal), the more the merrier!!
  4. In one of your terminals, type in xterm&. (This opens yet another terminal, called an X terminal, it just looks a little different from the other terminals: The ampersand means to run the command/process in the background.)
  5. Type in mkdir cs211 to make a folder/directory where you will store your cs211 stuff.
  6. Type in cd cs211 to change directory.
  7. You may like to make further subdirectories/folders by typing mkdir labs or mkdir python etc.
  8. 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.
  9. TASK 1 Using the command ps -alx, find (and submit) the process ID, and corresponding command, of three processes whose parent process is init() (whose process ID is 1).
  10. 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 python myfile.py. Make yourself familiar with the programs orphanZombie.py and or2.py at http://www.maths.nuigalway.ie/~gettrick/teach/cs211/progs/, and run them to see what they do.
  11. TASK 2 Write (and submit) 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.
  12. TASK 3 Write (and submit) 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 GC1 - 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.)
  13. TASK 4 Study the programs pipedemo.py and pipes2.py covered in lectures. Following this, write and submit 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 chile 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 chile process prints the reversed string to the screen.


© NUI, Galway