Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

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.

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M92486339
  • Price:- $70

Priced at Now at $70, Verified Solution

Have any Question?


Related Questions in Operating System

Question state the required answer precisely and then

Question : State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. What is the purpose of the command interpreter? Why is it usually separate fr ...

Question 1answer the following questions 10 marks a

Question 1 Answer the following questions: 10 marks a. Consider the following page reference string: 3, 1, 4, 1, 2, 3, 5, 3, 2, 1, 2,5, 4, 3, 5, 2, 4,2, 5,3 Using the above page reference string display the contents of t ...

Question research hex editors available for mac os and

Question : Research hex editors available for Mac OS and Linux. Based on the documentation, how easy would validating these tools be? Select at least two hex editors for each OS, and discuss what you would do to validate ...

Show all stepssuppose that the following processes arrive

Show all steps Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. in answering the questions, use non-preemptive scheduling and base all dec ...

Question you are a security administrator responsible for

Question: You are a security administrator responsible for providing secure configuration requirements for new laptop deployments. After reading Module 2 of Certified Secure Computer User v2exercises, apply the configura ...

Discussion question this research assignment will give

Discussion Question : This research assignment will give further information on the nature and workings of multi-tasking and multi-processing operating systems. All information reported in this assignment is to be in the ...

Taskyour job in this assignment is to create two virtual

Task Your job in this assignment is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these VM's is to offer services to a user base. The ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Consider a computer embedded in the control of a manned spacecraft. Would it require an ...

Question description of lasa in this assignment you will

Question: Description of LASA: In this assignment, you will select a real-world operating system (can be for a PC, server, tablet, handheld, or embedded device). You will introduce the operating system and its components ...

Question note apa format 250 words and three reference

Question: Note: APA format 250 words and three reference without plagarism Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As