Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

Objective - Tiny Shell (tish)

In this exercise you will write a small shell program to run different programs in foreground and background mode.

Background

Usually when you login on to the system the program that takes control and takes care of your requests is the "shell" program. In this exercise you will implement only a small portion of the shell capabilities.

Assignment

Your assignment is to build a program "tish" that will implement the following shell services:

  • Run programs in foreground and background;
  • List all processes that currently run in the background.
  • Kill a process running in the background.

The precise requirements are as following:

  • Your shell should give a user "tish>>" as a prompt;
  • There are two types of commands that "tish" should understand:
    • External commands: the command name is, in fact, the name of an executable file. When an external command is requested this means that the corresponding executable file should be run.
    • Internal commands: commands that are "built-in" in the "tish" shell. For example, the "bye" command does not correspond to any executable file. Instead, it causes "tish" to execute the exit system call. Below we specify which internal commands you are required to implement.
  • Execution mode for external commands:
    • Foreground: a command is given in the following form tish>> . In this mode "tish" does not return the prompt until the executable file that corresponds to the command finishes.
    • Background: a command is given in the same format as in the foreground mode, but the last parameter in the parameter list should be '&'. for example:
      tish>> emacs &
  • Example of running external commands:
    • tish>> emacs my_file.
  • List of Internal commands you are required to implement:
    • bye : terminate "tish". All background processes should be terminated. (Note that the real shell does not do this).
    • jobs : list of all background jobs in the following format: , in the order of creation.
    • kill :terminate the process corresponding to the specified pid by sending SIGTERM signal.

Recommendations and additional requirements:

  • You are required to use fork() and execvp(const char* file, const char* argv) system calls. execvp() is a version of the execve() system call in which the path and environment does not need to be specified. The file name should not! include a '/' char. If it does you should output a compatible error message. In this assignment you are required to deal with list of parameters no larger than 2. You are not required to check the type of the parameters you have received just to pass them on to the execvp() call in the right format.
  • You are NOT allowed to use the library function system() instead of fork/exec. This is because system() itself forks a new shell that forks the specified command. Using system() is absolutely prohibited in this exercise.
  • You may not assume that the user always specifies a correct input. For instance, the user may specify non-existent command name, or wrong parameters. Your program should print an appropriate error message. Note that empty or pure white space(s) command is not an error, and should be simply ignored and prompt should be repeated immediately
  • In the foreground execution mode a running process is terminated using the "Ctrl-C" key combination. Pressing this combination generates signal SIGINT that is sent to the control terminal process group. Since both "tish" and all its children are members of this group they have to take care of this signal. It should be handled differently in the main loop of "tish" (the one that provides the prompt and reads the user's input), and in a foreground child Namely:
    • Main loop of "tish" (father): ignores SIGINT, catches SIGTERM (may be sent by an outside application, e.g., tcsh);
    • Foreground child: default behavior, i.e., termination
  • When a process finishes, it enters the zombie state. A process will remain in this state as long as it father is alive. Since all external commands are children of "tish" and "tish" may be kept alive very long, the process table will eventually fill up. In this exercise you can ignore the fact that the number of zombie files in the system is limited.
  • "tish" command line is limited to 1024 characters
  • You may not assume correctness of arguments for internal commands (letters instead of numbers, negative numbers, etc. all should be checked)

System Calls and Functions List

  • fork();
  • execvp();
  • wait();
  • signal();
  • kill();
  • exit();

You may use "stdio" library functions in order to read user's input and to print the messages. You are advised to use string library functions, such as strtok() to manipulate strings.


 

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M9571574
  • Price:- $80

Guranteed 48 Hours Delivery, In Price:- $80

Have any Question?


Related Questions in Operating System

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. Briefly describe the following concepts and indicate how they are related in the context ...

Question what do you see as the major differences between

Question : What do you see as the major differences between UNIX/Linux and other operating systems, such as Windows and Mac OS X? The response must be typed, single spaced, must be in times new roman font (size 12) and m ...

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

Catalog course descriptionin this course students carry out

Catalog Course Description In this course students carry out independent research in a significant technical area of information, network, and computer security. The student is to investigate a technical area, research i ...

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

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

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

Assignment -building a multi-threaded web server using c

Assignment - Building a multi-threaded web server using C and p threads, following the model from the lecture. Your program will have one thread acting as a dispatcher thread, listening fornetwork connections with reques ...

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

  • 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