Posted: March 8th, 2017

The first process should continue displaying the prompt one more time. The program must end when the user enters T.

What you need to do for the first lab 1- Decide what Linux platform you will use for all the labs and write a simple C/C++ program and make sure you can compile it correctly. For the platform you use, you have a choice of using: -Element-K -Your own stand-alone Linux distribution installed on a PC -Cygwin (I think Cygwin would be the best choice). If you select Cygwin as your choice, go to Cygwin website and install it. During one part of the installation process, you will be asked to select Packages make sure to select debug and under debug select gcc-debuginfo and Cygwin-debuginfo. Also under Editors you can select an editor that you prefer to use.

To install an IDE, you may go to Download and install Netbeans IDE 7.3.1 – C/C++ Bundle (or All). Next follow the instructions at: and install Cygwin. Make sure to add define the path as it is explained.

2- Write a simple Hello World C/C++ program , compile it and run it (under Linux environment).

3- Learn about system calls such as fork( ), exec(), wait( ), pipe( ), and sleep( ). Read man pages of these system calls for details. I have placed a document under the Doc Sharing called Unix System Programming which further defines these system calls. Also under the shell Webliography there is a tutorial called: YoLinux Tutorial: Fork, Exec and Process control 4- I have placed a skeleton code for lab1 document under the Doc Sharing. This file is not complete and it should give you a better idea on how to do lab1.

The lab presented in week-1 iLab is divided into three parts. For the next three weeks, we will do one part of it as it is described in the iLab. This lab is a simulation to show how part of an operating system works. We write the simulation code in C/C++ language and the operating system we use is Linux.

Before describing the lab In ECET-330 we learned that the job of the CPU is to fetch, decode, execute an instruction and continue these steps. Imagine we have one processor and so many programs such as email, word, C compiler and other things running in parallel. In other words, you can check your email while you listen to a song played by your PC and compile a code all at the same time. As described above, CPU and fetch and execute only one instruction at a time. Now the question is how one processor can handle all these tasks in parallel. The Operation System (OS) divides time in small portions (quantum of time) and assigns CPU to each process (email, word, or the compiler). To make this work, a queue is needed to make all the processes wait for their turn. A timer and interrupt system is needed to interrupt the CPU after the quantum time for a process is over. Structures are needed to save all the register values of the CPU and let the registers to be used by the other process. Then after the first process gets the CPU for another time, the saved CPU values will be placed in CPU registers one more time. It looks like as if each process has its own CPU.

What is the idea of these three labs? In the first three labs of this course, we want to simulate what is explained in the above paragraph. For example in week-2, a structure or class is defined which will play the role of CPU registers. The code you will write in week2 will do the function of the CPU. In other words, CPU will be a simulation of the CPU. An integer field is designated for PC (program counter) and another field for the accumulator. Also, to simplify this simulation, the iLab has defined a simple set of instruction set. For example, your code reads the next instruction from the array or a file (i.e. this is the simulation of CPU fetching the next instruction). Then using a switch structure, your code decides if the instruction is a S 20 or A 20 and so on (i.e. this is the simulation of decoding the instruction by the CPU). If the instruction is S 20 then the value 20 is stored in a variable (i.e. this is the simulation of the execution cycle of the CPU where the value 20 is placed in the accumulator). To make this simulation realistic, two processes will be created that will communicate to each other using a pipe. Creating processes and pipes are all new to you. So I have placed some documents in the doc sharing to describe how these can be done. Rather than having a timer and an interrupt system to interrupt CPU after a quantum amount of time, we will use the keyboard and type characters such as Q, U, P and T. When the user types character Q, it means one time unit has passed. So CPU can fetch and execute the next instruction. Note that the CPU is also a simulation. In other words your code will read the next instruction from an array or a file and execute that instruction. The set of instructions that we have are defined in the iLab and are simple as well. For example the instruction S 20 means to set the value of an integer variable to 20. While this program (process) is performing these tasks another process reads the keyboard for characters such as Q, U, P and T. These two processes communicate with each other using a pipe. Pipe is like a queue that is shared by the two processes. The first process writes the character to the pipe (to the queue) and the other process gets it from the other end of the pipe. What portion of the iLab belongs to lab1 For lab1, we do not need to worry about CPU simulation and process control block. All we need to do is to create two processes that communicate with each other using a pipe. Your program should output a prompt such as $ and wait for the user input. The use can input one of these four characters (Q, U, P or T) as described below: 1. Q: End of one unit of time. 2. U: Unblock the first simulated process in blocked queue. 3. P: Print the current state of the system. 4. T: Print the average turnaround time, and terminate the system.

For the first week’s lab we do not need to implement the function for each character. All you must do is to send this character to a pipe. The process at the other end of the pipe will receive this character. Then it should display what character it is received. The first process should continue displaying the prompt one more time. The program must end when the user enters T. The code you write for this week’s lab is called the commander process.

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
Live Chat+1-631-333-0101EmailWhatsApp