Design and implement a process model and os utility

Assignment Help Operating System
Reference no: EM131677638

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 <stdio.h>
...

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 <stdio.h> #include <unistd.h>

#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.

Reference no: EM131677638

Questions Cloud

Describe the reasons that ddt is no longer used in the us : Describe the reasons that DDT is no longer used in the United States. Why is it still used in many other countries?
Discuss non-renewable sources of energy : Calculate the amount of fuel consumed to generate this electricity using non-renewable sources of energy
Identify the core competencies of walmart : Identify the "core competencies" of Walmart and explain why these core competencies are costly to imitate by their rivals.
Discuss ethanol as a transportation fuel : Identify at least three advantages and three disadvantages of its use. Also, assess the government's policy regarding ethanol and make a recommendation
Design and implement a process model and os utility : 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.
Prepare a contribution format income statement for the month : Problem - Sales Mix; Multiproduct Break-Even Analysis - Prepare a contribution format income statement for the month based on the actual sales data
Internet access from mobile locations : How has teleconferencing changed with global Internet access from mobile locations? What additional roles is conferencing taking on in business?
Forms of deviant workplace behavior : Could you describe an experience of an organization that was effective in dealing with one of the forms of Deviant Workplace Behavior?
Describe structures that are shared by multiple species : Describe structures that are shared by multiple species due not to common ancestry but due to similar adaptive responses - What is the significance

Reviews

Write a Review

Operating System Questions & Answers

  Implementation of algorithms for process management

The Shortest Job Next (SJN) algorithm queues processes in a way that the ones that use the shortest CPU cycle will be selected for running rst.

  Develop a user mode command interpreter

Develop a user mode command interpreter which support list-short.

  Memory allocation in operating system

Analysis and implementation of algorithms for memory allocation in operating system, Explain First- t and best- t methods are used in memory allocation in operating systems.

  Stand alone child process

Forking the child process

  Write a multi-threaded program

Write a multi-threaded program to solve producer and consumer problem

  Marginal and average cost curves

n a competitive market place (pure competition) is it possible to continually sell your product at a price above the average cost of production.

  Simulating operating systems scheduling

Simulate the long-term scheduler, the short-term scheduler and the I/O scheduler of the computer using the First-Come-First-Serve algorithm.

  Issues with trusted platform module

Research paper discussing the issues with Trusted Platform Module (TPM)

  Threads

Explain a complication that concurrent processing adds to an operating system.

  Design and programming

Use the semaphore methods to control the concurrency of the solution

  Virtual machines

Virtual machines supported by a host operating system

  Discuss an application that benefits barrier synchronization

Discuss an application that would benefit from the use of barrier synchronization

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd