Project 1: Implementing a Shell 1 Overview In this individual project you will have to design...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Project 1: Implementing a Shell 1 Overview In this individual project you will have to design and implement a simple shell command interpreter, called mysh. The basic function of a shell is to accept lines of text as input and execute programs in response. The shell must be able to execute built-in commands in a process different from the one executing mysh. 2 Requirements When first started, your shell should initialize any necessary data structures and then enter a loop of printing a prompt, e.g. "mysh#", reading any commands entered by the user and executing them. 2.1 Simple execution of commands mysh executes a program in the foreground, waits for it to terminate, and then resumes control, e.g. mysh# vi would launch the vi editor, the user can then perform text processing and after the user quits vi, control is returned back to the shell. The user shouldn't have to type in the full path to executables as long as they are within the search path specified the environment by the PATH variable. In your initial implementation mysh should spawn a child process and block wait for the child to terminate. The relevant system calls here are fork(), the wait() and exec() families of calls, and exit(). 2.2 Parsing the command line When parsing the command line, mysh should ignore all whitespace. You might find the isspace and strtok man pages useful. Please keep in mind that your commandline parser should work, but we do not expect it to be particularly fancy. For example, and should not be treated specially by the parser. We'd much rather see you spend a lot of effort on the job control features of your shell. 2.3 Built-in commands Mysh should support the following built-in commands. • jobs: Print a list of commands that are currently running or suspended. This list should include an integer, the command line that started the respective program and the status (Running or Suspended) of the program, e.g. mysh# jobs [1] Running [2] Running [3] Suspended [4] Suspended xemacs project1.tex xdvi projectl vi firefox • kill %job: Sends a SIGTERM signal to the specified job, e.g. mysh# kill $2 would terminate the xdvi program from the previous example. • fg %job: Continue executing the specified command in the foreground, e.g. mysh fg #3 would bring the vi program to the foreground. The shell would then wait for the user to either terminate the vi program or to suspend it using Control-Z. • bg %job: Put the specified job in the background, continuing it if it was suspended, e.g. if a user had started the firefox web browser, and suspended it using Control-Z, then mysh# bg $4 should let the browser continue running in the background. • pwd: Print the current working directory. • cd path: Change the current working directory to specified path. 3 Hints and Tips • The man pages are your friends! Manpages of particular interest would be: fork() exit() exec(), execl(), execv(), execle(), execve(), execip(), execvp() wait(), waitpid() kill() isspace(), strtok() • This project should be developed on a UNIX OS. You are free to use any flavor of UNIX you want for development. It should contain at least three parts: 1) an introduction to the basic structure of your shell; 2) a list of which features are fully implemented, partially implemented, and not implemented; and 3) a discussion of how you tested your she correctness. Project 1: Implementing a Shell 1 Overview In this individual project you will have to design and implement a simple shell command interpreter, called mysh. The basic function of a shell is to accept lines of text as input and execute programs in response. The shell must be able to execute built-in commands in a process different from the one executing mysh. 2 Requirements When first started, your shell should initialize any necessary data structures and then enter a loop of printing a prompt, e.g. "mysh#", reading any commands entered by the user and executing them. 2.1 Simple execution of commands mysh executes a program in the foreground, waits for it to terminate, and then resumes control, e.g. mysh# vi would launch the vi editor, the user can then perform text processing and after the user quits vi, control is returned back to the shell. The user shouldn't have to type in the full path to executables as long as they are within the search path specified the environment by the PATH variable. In your initial implementation mysh should spawn a child process and block wait for the child to terminate. The relevant system calls here are fork(), the wait() and exec() families of calls, and exit(). 2.2 Parsing the command line When parsing the command line, mysh should ignore all whitespace. You might find the isspace and strtok man pages useful. Please keep in mind that your commandline parser should work, but we do not expect it to be particularly fancy. For example, and should not be treated specially by the parser. We'd much rather see you spend a lot of effort on the job control features of your shell. 2.3 Built-in commands Mysh should support the following built-in commands. • jobs: Print a list of commands that are currently running or suspended. This list should include an integer, the command line that started the respective program and the status (Running or Suspended) of the program, e.g. mysh# jobs [1] Running [2] Running [3] Suspended [4] Suspended xemacs project1.tex xdvi projectl vi firefox • kill %job: Sends a SIGTERM signal to the specified job, e.g. mysh# kill $2 would terminate the xdvi program from the previous example. • fg %job: Continue executing the specified command in the foreground, e.g. mysh fg #3 would bring the vi program to the foreground. The shell would then wait for the user to either terminate the vi program or to suspend it using Control-Z. • bg %job: Put the specified job in the background, continuing it if it was suspended, e.g. if a user had started the firefox web browser, and suspended it using Control-Z, then mysh# bg $4 should let the browser continue running in the background. • pwd: Print the current working directory. • cd path: Change the current working directory to specified path. 3 Hints and Tips • The man pages are your friends! Manpages of particular interest would be: fork() exit() exec(), execl(), execv(), execle(), execve(), execip(), execvp() wait(), waitpid() kill() isspace(), strtok() • This project should be developed on a UNIX OS. You are free to use any flavor of UNIX you want for development. It should contain at least three parts: 1) an introduction to the basic structure of your shell; 2) a list of which features are fully implemented, partially implemented, and not implemented; and 3) a discussion of how you tested your she correctness.
Expert Answer:
Answer rating: 100% (QA)
Answer 1 Introduction The goal of this project is to design and implement a basic shell comm... View the full answer
Related Book For
Posted Date:
Students also viewed these operating system questions
-
You have to design and implement a digital system on FPGA for 4x4 matrix multiplication. Your System can read any matrix values. Design of matrix multiplier must consists of four main parts: Signed...
-
Perform the following conversions. Note that you will have to convert units in both the numerator and the denominator. a. 88 ft/s to miles/hour: use 5,280 ft = 1 mi. b. 0.00667 km/h to meters/second
-
Perform the following conversions. Note that you will have to convert units in both the numerator and the denominator. a. 3.88 102 mm/s to kilometers/hour b. 1.004 kg/L to grams/milliliter
-
On November 1, 2020. Cheng Company (a U.S.-based company) forecasts the purchase of goods from a foreign supplier for 280,000 yuan. Cheng expects to receive the goods on April 30, 2021, and make...
-
Using the z distribution table, find the proportion of the total area for the following, draw a picture of each, and shade in the target area. a. Between a z score of 0.00 and a z score of 1.64: b...
-
Calculate E cell for each balanced redox reaction and determine if the reaction is spontaneous as written. a. O(g) + 2 HO(1) + 4 Ag(s) b. Br(1) 21 (aq) c. PbO (s) + 4H+ (aq) + Sn(s) 4 OH(aq) + 4 Ag+...
-
At a given radial location, a 15-mph wind against a windmill results in the upstream (1) and downstream (2) velocity triangles shown in Fig. P12.4. Sketch an appropriate blade section at that radial...
-
Prepare Carissa Communications multi-step income statement for the year ended July 31, 2016. Carissa Communications reported the following figures from its adjusted trial balance for its first year...
-
A wire is first bent into the shape of a square. Each side of the square is 10 cm long. Then the wire is unbent and reshaped into a rectangle. If the length of the rectangle is 13 cm, what is its...
-
You have been hired as a consultant by Molycorp, a rare earth mineral mining company headquartered in Colorado. Your job is to evaluate a huge financing decision the company faces as part of its...
-
The following chemical formula is typical of: Select one: amino acid protein sugar fatty acid
-
3. Explain briefly how conflict resolution can be done in foreign project valuation (aka multinational capital budgeting) when different claimant groups differ in project assessment and consequent...
-
A firm contemplates buying an asset for $75,000.It will use the asset for 3 years, then sell it for $33,000.The sale will close out the asset's CCA (capital cost allowance) account.The CCA rate for...
-
What extent do you think it is appropriate for central banks to compensate for inaction by the legislative and executive branches? What do you think are the normative implications for democracy in...
-
Regarding the Darden Case - Ferrari: the 2015 IPO What is your estimate of enterprise value for Ferrari? What is your estimate of the value of the firm's equity? What is your estimate of the value...
-
For the system given in the figure, u(t) voltage is applied to the solenoid which is modeled as a system consists of a resistive and an inductive element. Solenoid generates a force u(t) which is a...
-
Murphy Corp. manufactures auto parts. The firm continued to report improved operations in 2021. Sales increased rapidly in 2022 and the firm reported net income after taxes of $55,000. Depreciation...
-
Write a program to move a signed number from smaller register to bigger register. Hint: movzx ax, bl Topic: Data Related Operators and Directives in assembly language
-
Carmean Products Inc. sold 32,350 shares of common stock to stockholders at the time of its incorporation. Carmean received $42 per share for the stock. Required: 1. Assume that the stock has a $22...
-
Anderson Lawn Service provides mowing, weed control, and pest management services for a flat fee of $300 per lawn per month. During November, Anderson collected $9,900 in cash from customers, which...
-
Hill Motor Company, one of the country's largest automobile manufacturers, disclosed the following information about its inventory in the notes to its financial statements: Inventories are stated...
-
Consider the Gompertz model in Eq. (12.35). Graph the expectation function for \(\theta_{1}=1, \theta_{3}=1\), and \(\theta_{2}=\frac{1}{8}, 1,8,64\) over the range \(0 \leq x \leq 10\). Equation...
-
Consider the following observations: a. Fit the nonlinear regression model \[ y=\theta_{1} e^{\theta_{2} x}+\varepsilon \] to these data. Discuss how you obtained the starting values. b. Test for...
-
Consider the model \[ y=\theta_{1}-\theta_{2} e^{-\theta_{3} x}+\varepsilon \] This is called the Mitcherlich equation, and it is often used in chemical engineering. For example, \(y\) may be yield...
Study smarter with the SolutionInn App