Operating Systems - Laboratory Exercise | CECS 326, Lab Reports of Operating Systems

Material Type: Lab; Class: Operating Systems; Subject: Computer Engr & Computer Sci; University: California State University - Long Beach; Term: Fall 2005;

Typology: Lab Reports

Pre 2010

Uploaded on 08/18/2009

koofers-user-hx0
koofers-user-hx0 ๐Ÿ‡บ๐Ÿ‡ธ

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CECS 326 โ€“ Lab Exercise 9/1/05 (10 points) : Due Tuesday, 9/6/05, in Lab
We have learned that things work in a UNIX/Linux environment as follows:
1. After we log in, a program called the shell is started. The shell displays a prompt indicating that it is ready
to receive instructions.
2. We type in a command and press ENTER.
3. The shell makes sense out of what we request (or complains if it cannot).
4. The shell then starts a child process, and tells child process to execute the utility code we requested.
5. The utility program runs and produces output where appropriate.
6. When the utility code reaches its end, it signals the shell that it is finished and it then terminates.
7. Upon receiving information that the last program has terminated, the shell displays another prompt and
waits for our next instruction.
Many utility programs accept input from the arguments that we type with the command name. For example,
when we type cal 2005 we are actually requesting for the execution of the cal utility program with string
โ€œ2005โ€ as the input for its execution. The cal utility program, however, does not read the string โ€œ2005โ€
directly. Rather, the shell program reads it, and passes it onto the cal utility program. Therefore cal as well as
many other utility programs must be designed to receive and extract all the arguments that shell reads in as part
of our command. In this lab exercise, you are to write a simple C++ program that mimics the Linux command
echo without having to provide the support for options. (Hints: You would need to use argc and argv for your
implementation.)
Do the following:
1. Create a subdirectory named ex-9-1-05 within your htdocs/cecs326 subdirectory. Set its permission to
world readable and world executable.
2. Write a C++ program that mimics the echo utility program, save it in your ex-9-1-05 subdirectory as
myecho.cpp.
3. Compile your myecho.cpp into an executable named myecho, which should execute the same way as echo.
4. Hand in a hardcopy of your C++ program, and demo the execution of your โ€œmyechoโ€ command.
Sample run of myecho (Linux> below represents Linux prompt):
Linux>myecho 1 2 3
1 2 3
Linux>myecho 1 2 3 4
1 2 3 4
Linux>myecho one two three four
one two three four
Programming guidelines:
1. All programs must be preceded with a comment section that consists of the following:
Full pathname of the program file
Your full name
Course number and course title
Lab exercise id
Due date of lab exercise
Program description
2. All programs must have comments, regardless how simple the program is.
3. All programs must be modular.
4. Use meaningful names for variables and functions.

Partial preview of the text

Download Operating Systems - Laboratory Exercise | CECS 326 and more Lab Reports Operating Systems in PDF only on Docsity!

CECS 326 โ€“ Lab Exercise 9/1/05 (10 points) : Due Tuesday, 9/6/05, in Lab

We have learned that things work in a UNIX/Linux environment as follows:

  1. After we log in, a program called the shell is started. The shell displays a prompt indicating that it is ready to receive instructions.
  2. We type in a command and press ENTER.
  3. The shell makes sense out of what we request (or complains if it cannot).
  4. The shell then starts a child process, and tells child process to execute the utility code we requested.
  5. The utility program runs and produces output where appropriate.
  6. When the utility code reaches its end, it signals the shell that it is finished and it then terminates.
  7. Upon receiving information that the last program has terminated, the shell displays another prompt and waits for our next instruction. Many utility programs accept input from the arguments that we type with the command name. For example, when we type cal 2005 we are actually requesting for the execution of the cal utility program with string โ€œ 2005 โ€ as the input for its execution. The cal utility program, however, does not read the string โ€œ 2005 โ€ directly. Rather, the shell program reads it, and passes it onto the cal utility program. Therefore cal as well as many other utility programs must be designed to receive and extract all the arguments that shell reads in as part of our command. In this lab exercise, you are to write a simple C++ program that mimics the Linux command echo without having to provide the support for options. (Hints: You would need to use argc and argv for your implementation.) Do the following:
  8. Create a subdirectory named ex-9-1-05 within your htdocs/cecs326 subdirectory. Set its permission to world readable and world executable.
  9. Write a C++ program that mimics the echo utility program, save it in your ex-9-1-05 subdirectory as myecho.cpp.
  10. Compile your myecho.cpp into an executable named myecho , which should execute the same way as echo.
  11. Hand in a hardcopy of your C++ program, and demo the execution of your โ€œ myecho โ€ command. Sample run of myecho (Linux> below represents Linux prompt): Linux>myecho 1 2 3 1 2 3 Linux>myecho 1 2 3 4 1 2 3 4 Linux>myecho one two three four one two three four Programming guidelines:
  12. All programs must be preceded with a comment section that consists of the following: Full pathname of the program file Your full name Course number and course title Lab exercise id Due date of lab exercise Program description
  13. All programs must have comments, regardless how simple the program is.
  14. All programs must be modular.
  15. Use meaningful names for variables and functions.