0% found this document useful (0 votes)
22 views

Homework 1

This document outlines 3 homework problems for a computer operating systems course. Problem 1 involves writing a C/C++ program to replace the Unix command shell. It should print a prompt, read commands, execute programs or exit based on the command, and handle errors. Problem 2 asks about how a scheduling algorithm favors I/O-bound over CPU-bound programs. Problem 3 asks about the minimum and maximum number of processes that can be in different states in a multiprocessor system.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Homework 1

This document outlines 3 homework problems for a computer operating systems course. Problem 1 involves writing a C/C++ program to replace the Unix command shell. It should print a prompt, read commands, execute programs or exit based on the command, and handle errors. Problem 2 asks about how a scheduling algorithm favors I/O-bound over CPU-bound programs. Problem 3 asks about the minimum and maximum number of processes that can be in different states in a multiprocessor system.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

COP 4600 - Homework 1

Due February 15, 2008

Problem 1:
Write a C/C++ program which replaces the command shell in Unix.
 After started, it prints a prints a prompt “>” and reads a command line terminated
by newline.
 If the command line is “exit”, it terminates.
 If the command line is something other than “exit”, it interprets the first word as
the name of a program to execute, and the others as parameters. It uses fork() +
exec() to start the program with the corresponding parameters.
 If the command line terminates in “&”, the shell returns the prompt and is ready
to receive another command. If it is not, the shell waits until the started program
is terminated (using the waitpid() call).
 Print an error message for all error situations encountered.

See the linked file for a short tutorial on fork and exec.

As a note: the easiest way to program this assignment is if you are using a native Unix
system, such as Linux. Alternatively, you can use the Cygwin environment in Windows.

Submit the code as a single .c or .cpp file.

Problem 2:
An I/O bound program is one that, if run alone, would spend more time waiting for I/O
than using a processor. A processor bound program is the opposite. Suppose a short-term
scheduling algorithm favors those programs that have used little processor time in the
recent past. Explain why this algorithm favors I/O bound programs and yet does not
permanently deny processor time to processor bound programs.

Problem 3:
Consider a computer with N processors in a multiprocessor configuration. What is the
minimum and maximum number of processes that can be in each of the Ready, Running
and Blocked states?

You might also like