This will be individual projects the main purpose of this


Operating Systems Assignment Project: UNIX Shell and Program Selection Feature using GCP Virtual Machine

Objectives:

1. Understand one commonly used process model to execute program instructions.
2. Understand the effect of practical factors on implementing OS utilities.
3. Commonly used means to communicate with both the OS and the user.
4. Reasonable ability to implement OS functionality using C.
5. Low-level programming development and debugging skills.
6. Gain experience with an industry standard OS such Unix and Linux
7. Gain experience with Google Cloud Platform (GCP) Virtual Machine

This will be individual projects. The main purpose of this project assignment, i.e. Project 1, is to design and implement a process model and OS utility, i.e., Shell. In this project, you can use only Python (with some limitations), C or C++ programming language with gcc or g++ compiler under Google Cloud Platform (GCP) VM used in exercise lab. Therefore, there is no requirement of GUI.

This project consists of designing a Python, C or C++ program to serve as a shell interface that accepts user commands and then executes each command in a separate process. The shell provides the user a prompt after which the next command is entered. The example below illustrates the prompt ubos> and the user's next command: i.e., cat prog.c (This command displays the file prog.c on the terminal using the UNIX cat command)

ubos> cat prog.c #include
...

One technique for implementing a shell interface is to have the parent process first read what the user enters on the command line (in this case, cat prog.c), and then create a separate child process that performs the command. Unless otherwise specified, the parent process waits for the child to exit before continuing. This is similar in functionality to the new process creation illustrated in Figure 3.10 (text book) and Exercise Lab.

The separate child process is created using the fork() system call and the user's command is executed by using one of the system calls in the exec() family (see Section 3.3.1 in the textbook).

A C program that provides the basic operation of a command line shell is given below. The main() function presents the prompt ubos> and outlines the steps to be taken after input from the user has been read. The main() function continuously loops as long as should_run=1; when the user enters exit at the prompt, your program will set should_run=0 and terminate.

#include #include

#define MAX_LINE 80 /* 80 chars per line, per command */ int main(void)
{
char *args[MAX_LINE/2 + 1];
/* command line (of 80) has max of 40 arguments */ int should_run = 1;

int i, upper;

while (should_run){ printf("ubos>"); fflush(stdout);

/**
* After reading user input, the steps are:
* (1) fork a child process
* (2) the child process will invoke execvp()
* (3) if command included &, parent will invoke wait()
*/
}

return 0;
}

This project is organized into two parts: (1) creating the child process and executing the command in the child, and (2) modifying the shell to allow selection of program from current directory.

Part A: Creating a Child Process

The first part of the project is to modify the main() function in the code above so that a child process is forked and execute the command specified by the user. This will require parsing what the user has entered into separate tokens and storing the tokens in an array of character strings (args in the code). For example, if the user enters the command "ps -ael" at the prompt,

ubos> ps -ael

the values stored in the args array are:

args[0] = "ps"
args[1] = "-ael" args[2] = NULL

This args array will be passed to the execvp() function, which has the following interface:

execvp(char *command, char *params[]);

where command represents the command to be performed and params stores the parameters to this command. For this project, the execvp() function should be invoked as execvp(args[0], args).

Part 2: Creating Program Selection Feature

The next task is to modify the shell interface program so that it provides a program selection feature that allows the user to access the available executable programs from the current directory. The user will be able to access all executable programs, i.e., all files that a user has executable permission, from a current directory by using the feature.

The commands will be consecutively numbered by alphabetical order (i.e., A-Z and 0-9) starting at 1, and the numbering will continue the last executable program.

The user will be able to list the executable programs by entering the command:

ubos> selection

As an example, assume that there are 5 executable files (or programs) in the current directory:

a.out ex1 ex2 test b.out

The output of selection command will be:

1 a.out
2 b.out
3 ex1
4 ex2
5 test

Your program should support the following execution feature, i.e., when the user enter an integer number N, the Nth command in the list is executed.

Continuing out example from above, if the user enters 1, the program ex1 will be executed. Any command executed in this fashion should be echoed on the user's screen.

The program should also manage basic error handling. If there are no executable file, "No executable file in directory."

Restrictions

• The code must be written in C and compile with the version of gcc installed in the lab.
• system() library call may not be used
• execvp() should be used among the exec*() family

Write-up

You should submit a write-up as well as your program. Your write-up should include analysis of performance measure with various parameter values, any known bugs, limitations, and assumptions in your program. This write-up should be in text-format and titled as ‘README'. It should be submitted along with your code. GA will use the ‘README' file to compile (or install) and run your program. If the GA has trouble with your program then he will contact you to makeup it.

Demonstration

After the project is submitted, each student demonstrates it in front of instructor and GA. The sign-up sheet will be provided before due date, and the student can choose 10 minutes time slot for the demonstration.

Solution Preview :

Prepared by a verified Expert
Operating System: This will be individual projects the main purpose of this
Reference No:- TGS02473168

Now Priced at $70 (50% Discount)

Recommended (96%)

Rated (4.8/5)