CS450-SUMMER 2008

HOMEWORK ASSIGNMENT  # 1

DUE – JUNE 15  11:59 P.M. (USA time).

 

The following directions apply to all assignments:

 

IMPORTANT: FOLLOW THE FOLLOWING DIRECTIONS OR YOU RISK OF HAVING YOUR SUBMISSION NOT GRADED!!!!!!!!

 

1.     Submit homework/project assignments to BLACKBOARD’s DIGITAL DROP BOX . Include your source code files, WHEN APPLICABLE, compiled code, WHEN APPLICABLE, executables, WHEN APPLICABLE, README file WHEN APPLICABLE, WORD file with your text typed answers etc as required (see 3 below).

 

2.     At the top of each source code file (if code is involved) include the following comments: //Author: Your name //

          Student ID: your school ID// Assignment # : ___ // Problem#___//Date:

 

3.     All assignments should include a WORD file named with the same name you use for the zipped name (see

           item 4). In the WORD file include : YOUR NAME, YOUR STUDENT ID, YOUR

          ASSIGNMENT #, DATE SUBMITTED. 

This WORD file also has the text answers to assignments or answers to project questions other than code (i.e. text exercises).

 Include any data if the assignment requires it. Any additional comments can be included in the WORD file

 (for example special instructions as to how to execute your program IN CASE OF A PROJECT).

 

4.     Create a folder and include all the assignment files in that folder. Name that folder the same name as the zipped file described next. Zip all files and use the following convention to name the zipped file: yourlastname_assignment#.zip . Upload the zipped file to the digital drop box of Blackboard.

 

5.     In addition, for any programs that involve executables written in C for UNIX environment or any script programs for UNIX environment, do the following: The source file and the executable file need to be stored in your UNIX account on the UNIX server. As part of checking your work the TA or I will try to execute your code from there. If your executable file is not there YOU WILL LOOSE THE POINTS (WE DON”T COMPILE FOR YOU!). Make sure that the proper permissions have been issued at the file level to make it executable. If your program does not execute, you loose the points.  Under your account name create a folder for the pertinent assignment (i. e. assignment1) and place your executables there. Remember that everything (as described in item 1) has also to be submitted on BLACKBOARD in order to receive credit.

 

 

NOTE:  ASSIGNMENTS ARE BASED ON BOTH THE TEXT AND ANY HANDOUTS PRESENT ON THE COURSE”S WEB SITE

 

PROBLEM 1 (2 points) ------Answer the following questions pertaining to hardware developments over the years.

  Do some research on the Internet and identify 4 Operating Systems that provide one of the following:

 

   Using a WORD document tabulate the following information for each of the Operating Systems identified above:

You must visit the web sites dedicated to each of the systems in order to collect information about each system.

 

PROBLEM 2 (2 points)----- Answer the following questions pertaining to the development of Operating Systems over the years.

1.                      By doing some research on the Internet identify the goals of GNU manifesto. Give a short history of its development and purpose. Identify its differences over “normal” UNIX. The inventor was Richard Stallman, a researcher who originally worked at MIT. Limit your answer to about half of a typed page (2 paragraphs).

2.                      By doing some research on the Internet write one or two (at most) paragraphs summarizing the history of the BSD Unix.

Answers exceeding the specified limit will be penalized grade wise (-1 or -2 points for extremely long). It is not to your advantage to copy and paste the answers. You should read the articles and summarize them in your own words.

 

 

PROBLEM 3 (2 points)

 

1.      Do exercise 1.7 from text

2.      Do exercise 1.5 from text

                       

 

PROBLEM 4 (3-points)

 

 

                        Write a script for UNIX Bash shell that performs as a calculator. Name the script file calc.src.

Command structure: $./calc.src arg1 arg2

Script functionality: Adds, subtracts, multiplies, divides, or gives the remainder of a division if asked in the options part of the command. The user provides the name of a text file in arg1. The file has two numbers (integers or decimals - they can be negative) and the operations one line for each operation. Argument 2 is the name of the file that the user designates for the results to be stored. The integers provided by the user , the result also appears on the screen.

                        Command structure options:  

§   a  means add

§  s means subtract

§  m means multiply

§  q means quotient

§  r means remainder

Your program first validates by making sure that the user entered the proper arguments. If not then a message is shown on the screen indicating the error.

Your program also checks to make sure that the file designated by the user has write and read rights and if not it sets the rights to read and write for all users and groups.         

Example of the arg1 file:

1.35   2.50   a                                                                                                                                                                         

4.00   3.20   m

6.00  3.25     s

Example of error message: # ./calc.rsc  input.txt  output.txt

              Output: # Error input file was not opened

Output file should look like:

           

3.85

12.80

2.75

 

 

 PROBLEM 5 (3-  points)

 

This exercise is based on the text Project described on pages 74 through 78 in your text and on class lectures and explanations on how Linux uses system calls . You don’t actually have to compile the linux kernel (or any of the files you are asked to create ) but what you have to do is go through the steps of creating a new system call for Linux. You will be modifying the Linux source code files, provided to you in the “CLASS MATERIAL DOWNLOADS” page of the course ‘ s web site, and you will be adding any additional code files that you need to add.  The files from the Linux kernel source code are unistd.h and entry.S

Create a new system call that does the following:

§  The system call takes two integers ads them up and returns their sum.

§  The system calls name is:  mysum.

Modify the unistd.h file to include the system call with the next available number after the last system call number already used.

Modify the entry.S file to include the new system call in the sys_call_table under the .data directive to the assembler.

Create a header file for your new system call routine that will be called by the system call handler. Call it mysum.h (for kernel usage).

Create the file mysum.c that represents the system call handler routine (for kernel usage).

Create a header file called mysum.h that will be placed in the Standard C library in user space. The functionality of this file is to call the proper macro from the unistd.h file that represents the system call with the proper arguments.

Create a user program that uses the system call to add two numbers, call it sample.c.

Submit: The modified unistd.h, the modified entry.S, and the modified Makefile script (modifications must be in red color in order for the TA to see the changes readily). The Makefile is only for the kernel code (only one makefiel to be submiited).

Submit: The files mysum.h (for kernel usage), mysum.c (for kernel usage), mysum.h (to be part of C library), and your user program sample.c

                        (7 items to be submitted total).

 

PROBLEM 6 (3-points)

 

                        The following code is executed (in Pascal):

                        procedure A (d: integer)

                                   

x1 : integer

 

                                    procedure B (a, b : integer)

 

                                    i , j : integer

 

            begin

 

                                                i: = a + b+j;

 

                                    end ;

 

                        begin

 

                                    Q (x1, d);

 

                        end

 

Currently the instruction that calls B (x1, d) is executed. Draw the Activation frames that are active in stack part of the memory at the current time. Label the frames by the name of the procedure they belong to. Show the contents of the frames and the corresponding addresses in stack. Assume fake decimal addresses as follows:

Beginning of stack (bottom part of stack) address 10000.

Beginning of text area 4000.

Each allocation takes 4 addresses.

Assume that each activation frame contains from the start to bottom: dynamic link, return address, static link, local variables, arguments to be passed to the next frame. Show the contents of the $fp and $sp registers as well as the contents of each address in the frames (note that in some cases dynamic and static links are the same). Show fake return addresses in the Activation Frames that relate to the proper area of memory.

Note: You have to assume that some main procedure is calling procedure A and that it is passing to it the variable d. Therefore for the main procedure show only the variable to be passed to A but allocate enough memory for it (also assume that only one local variable exists in main). The contents for the main can be empty but the addresses have to be correct. Assume that the main method stack has been allocated 200 addresses.

Show the result of i variable when B is executed if x1=3, d=4, j=2.

 

 

 

NOTE:

1.     Submit all files for all problems to Blackboard. Make sure you have a WORD file with the answers

2.     . Upload only the script for problem 4 on the cs450  UNIX server WITH THE PROPER PERMISSIONS MAKING IT EXECUTABLE.