Docsity

Programming Assignment 1: Linux and C Programming - Part 1 and 2, Assignments of Operating Systems

Toggle sidebar
bg1
Programming Assignment 1
Assigned: Monday Sept 8th, 2008
Due: Sunday 21st, 2008
Language to Use: C
Group Size: 2
Goal:
To acquaint you with Linux and to help you brush up on your C programming skills, you
will be reading system information from the proc files. To do this, you will need to make
use of system calls and file I/Os, which will prepare you for your next assignment.
Project Description:
Part 1) Using the Proc File System
You will write a program that displays the following information:
The current time (date not required but is in my example)
The total amount of time the computer has been on (uptime)
The current version of Linux
The current user’s ID
The total amount of memory the system has, in KB
The amount of memory currently being used, in KB
Furthermore if the program is called with the command line argument -p, you should
display a list of all processes running that are owned by the current user. For each process
you should display the following:
The PID (Process ID) of the process
The name of the process
You can test this functionality by making use of ctrl+z to minimize a program such as
emacs or pico (you can type the command fg to bring the program back to the
foreground).
Note: A makefile must be used for all projects in this class.
pf3

Partial preview of the text

Download Programming Assignment 1: Linux and C Programming - Part 1 and 2 and more Assignments Operating Systems in PDF only on Docsity!

Programming Assignment 1 Assigned: Monday Sept 8th, 2008 Due: Sunday 21st, 2008 Language to Use: C Group Size: 2 Goal: To acquaint you with Linux and to help you brush up on your C programming skills, you will be reading system information from the proc files. To do this, you will need to make use of system calls and file I/Os, which will prepare you for your next assignment. Project Description: Part 1) Using the Proc File System You will write a program that displays the following information:  The current time (date not required but is in my example)  The total amount of time the computer has been on (uptime)  The current version of Linux  The current user’s ID  The total amount of memory the system has, in KB  The amount of memory currently being used, in KB Furthermore if the program is called with the command line argument -p, you should display a list of all processes running that are owned by the current user. For each process you should display the following:  The PID (Process ID) of the process  The name of the process You can test this functionality by making use of ctrl+z to minimize a program such as emacs or pico (you can type the command fg to bring the program back to the foreground). Note: A makefile must be used for all projects in this class.

Part 2) Using strace Write a program that uses several system calls, at least 5 distinct system calls. Compile and run the program to ensure the system calls work accordingly. Record the output of your program (if any) into a file. (Hint: Use standard redirection “>” in Linux) Proceed to execute “strace” to trace the program written in Part 2a. Record the output of the trace into a file using the –o option. Perform the following experiment:

  1. Compile the program to generate the executable and trace the execution of the program using “strace”. Record the output into a file using the -o option.
  2. Delete the executable generated in step 1, and compile the program to generate the executable the second time. Trace the execution of the program using “strace”. Record the output into another file.
  3. Compare the output files generated in 1 and 2. Why are they different? How many system calls did your program call? How does this compare to the number viewed with strace? Part 3) Final Project Report  The project problem statement;  The steps your team took to solve the problem;  Why your solution uses the system calls/libraries that it does;  Problems encountered  Known bugs (also in project solution README file);  Division of labor between team members;  Cumulative log entries for the entire project  Responses to Questions in Part 2 Part 4) The Readme File  The Project team members' names and last four digits of each SSN  The Contents of your tar archive and a brief description of each file  The version of Linux that you used to complete the project (Alternatively, the name of the server you completed it on)  How to compile your executables using your Makefile  Known bugs and unfinished portions of the project  Special considerations or anything I should know when grading your solution Submission Instructions