[SOLVED] CPE434 Lab1-Overview of OS model and Programming Tools

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon lab1-nrshvc.zip (960.2 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

The goal of this lab is to familiarize you with your work environment for using the operating systems and to get started with linux processes.

For the most part these notes will apply to whichever environment you are using but you may have as yet unexpected issues with non windows10-wsl2-ubuntu configurations. Please contact the TA’s or myself if issues arise.

You will not have any physical access to UAH computers.  You will have to use them remotely. The only computers authorized for this course are the special ones we are setting up for scheduled, remote access to win10-wsl2-ubuntu

PartI: Entering, Compiling and Running a short program in Lab

For editing and preparing programs, the following notes will present an introduction to the vi text editor and the GNU C++ compiler. There is also a handout. There are several other editors available that you may wish to use instead of vi.

Type the following in terminal. vi filename.cpp (starts the editor) i (enter insert mode)

Following is the code that you will insert in your file:

Demo Code

Demo Code 1

 

Press: [ESC]-colon-wq-[Enter] after you are done typing the code. This will close the vi editor and save your work.

In terminal, g++ filename.cpp -o filename [Enter]

 

The above statement tells gnu compiler to compile your program into filename which is an executable

In terminal, /filename [Enter] should run the executable

Within vi, you can enter command mode at any time (escape-colon). You can move the cursor with either the j-down, l-left, h-right, k-up keys, or sometimes, but not always, with the cursor keys. A good thing to remember is escape-colon-quit-! which gets you out of the editor without saving the file (a good thing when something bad has happened).

To understand any command in linux, you can generally execute the man command, for example:

man fork

This should print the man page for fork,. If you are not sure of the command you want to use, you might try the command “apropos searchword”, which looks up commands which have searchword in the man page. Alternatively, you might want to buy a book on linux for a few dollars at the bookstore. Old books are generally ok for understanding commands.

Extra Demo Codes

Demo Code 2

The following code forks and prints the value of x from both the processes along with their process id.

 

Assignment 1

 

Analyze the output for the demo code above in terms of order in which output statements are printed.

Demo Code 3

 

Assignment 2

Hoe many processes are created from the above demo code? Explain

Demo Code 4

 

 

 

Assignment 3

What is orphan process? Is there any orphan process in above code? What is pid of orphan process if any is present?

Part II (Expanding the program in Demo 1)

Assignment 4

For homework, write a program that forks off 10 children, each of which will print out its pid and its serial number (1,2,3,4,5…10).

Report Format

Background (as instructed)

Procedure and Results (what I did −− and what happened when I did it!) Go through the lab step by step and describe what happens as you progress through it. Go idea to have another window open where you can record what is going on as it happens. Make sure to answer any questions that are asked and perform any procedure that is asked of you. These are often underlined. You can capture any output from the program by using the UNIX redirect operator that sends data that normally goes to the screen to a text file. This can be merged into your report.

Conclusion: Brief statement on what you believe was the major item(s) that you were able to learn and/or demonstrate.

  • lab1-nrshvc.zip