Homework 1 – System Calls, Computer Orgnization and Device Management

 

COP 4610/CGS5765, Introduction to Operating Systems, Fall 2003, Florida State University

¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾

Points: 100 points

Due: Week 5, Tuesday, September 23, 2003

  1. (30 pnts) After you read carefully the man page of exec system call regarding running script files (or called interpreter files), answer the following questions (assuming a UNIX system).

a)      (5 pnts) Why does a script file always start with “#!”?

b)     (10 pnts) Suppose we have a Perl script file named “simple-perl.pl” under the current working directory, which is given below.

#!/usr/bin/perl -w

@a = (1, 2, 3, 4, 5);

foreach $b (@a)

{

                $b *=3;

                print "b" . $b . "\n";

                print "a" . @a . "\n";

}

What is the equivalent command to “./simple-perl.pl” if we want to run “/usr/bin/perl” directly?

c)      (15 pnts) Outline the changes you need to make to the simple-shell.cc program given in the class so that it can be used as a command interpreter. The resulting interpreter accepts the internal commands and runs external programs.

 

2.      (15 pnts) Problem 7 in the textbook on page 149: part a only, i.e., only the algorithm for summing two floating-point numbers.

3.      (15 pnts) Problem 8 in the textbook on page 150.

4.      (15 pnts) Problem 9 in the textbook on page 150.

5.      (10 pnts) Problem 2 in the textbook on page 188. (Note that for a procecss tcompute and tdevice can be requested in any order; in other words, a process may perform I/O first and then computation.)

6.      (15 pnts) Problem 11 in the textbook on page 189.