Identify the critical sections in the above pseudo-code

Assignment Help Operating System
Reference no: EM132361081

Question 1

Answer the following questions:

a. Given five memory partitions (in order) of 100 KiB, 500 KiB, 200 KiB, 300 KiB, and 600 KiB, how would each of the first- fit, best-fit, and worst-fit algorithms place processes (in or- der) of 212 KiB, 417 KiB, 112 KiB, and 426 KiB? Which algorithm makes the most efficient use of memory?
b. Assume a 32 bit system, with a 2-level page table, with a page size of 4KiB (p1=10bits, p2=10bits, offset=12bits).
(i) A program on this system requires 16MiB in total: the program text segment uses 4MiB, the program data re- quires 2MiB, the program dynamically allocates 8MiB on the heap, and the stack utilises 2MiB.
How many page-table pages are required for this pro- cess? (Don't answer with just a number, explain your reasoning. Without your reasoning we cannot award part marks if your answer is incorrect.)
(ii) Describe the lookup steps within the page tables to find the physical address of the logical address 0x00403004.
(iii) If the reference time to access the physical memory frame is 20 nanoseconds. Assume that all required pages are in memory. How long does a paged memory reference take, if-
i. There is no TLB?
ii. There is a TLB, with an access speed of 0.05 nanosec- onds, but the TLB does not contain information on the required page?
iii. There is a TLB, with an access speed of 0.05 nanosec- onds, and the TLB contains information on this page?
(Do not answer with just a number, explain your rea- soning. Without your reasoning we cannot award part marks if your answer is incorrect.)

Question 2

A file is to be shared among different processes. The file can be accessed simultaneously by more than one process, up to a maxi- mum of 5 processes. In pseudo-code write a monitor to coordinate access to the file. For example:
FileMonitor M;

int main() {
...
M.RequestAccess();
/* Access file: open, read, close, etc. */ M.FinishedAccess();
...

}

Monitor FileMonitor {

/* monitor variables here */

void RequestAccess() { /* Code here */ } void FinishedAccess() { /* Code here */ }

}
The monitor pseudo-code needs to define monitor variables and the monitor functions.

Notes
• This is pseudo-code and not meant to be compiled and run. You will need to check the logic though.
• This is a monitor so mutual-exclusion is assured and does not need to be incorporated in the code.
• Assume that the monitor uses Mesa condition variables.
• As a starting point study Figure 5.19 (ed. 8, Figure 6.20) from the text book (Operating System Concepts, Silberschatz et el.).

Question 3

A two-way north-south highway through the mountains must pass through a narrow tunnel with only one lane. A south-bound or north-bound car can pass through the tunnel only if, when it ar- rives, there are no on-coming cars in the tunnel. Note, due to the length of the tunnel, at most 5 cars only are allowed in the tun- nel at one time-provided that they are all heading in the same direction.

In pseudo-code write the two processes north2south and south2north that allows cars to use the tunnel safely. As a starting point use the code below.

Hint: This is similar to the readers-writers problem except it is symmetric-north2south() is similar to south2north();
Remember: All Semaphores and variables must be initialised.
/* Shared Data between all processes */ Semaphore tunnel_mutex;
/* Shared Data between south2north processes */

Semaphore north_mutex; Semaphore going_north_max; int number_going_north;

south2north()
{

/* Add Synchronisation code here */ DriveNorthThroughTunnel();
/* Add Synchronisation code here */
}

/* Shared Data between north2south processes */

Semaphore south_mutex; Semaphore going_south_max; int number_going_south;

north2south()
{
/* Add Synchronisation code here */ DriveSouthThroughTunnel();
/* Add Synchronisation code here */
}

Question 4

Consider the following pseudo-code:
/* Global memory area accessible by threads */ #define N 100
struct frame *emptyStack[N]; struct frame *displayQueue[N];

int main() {
/*
** Initialise by allocating the memory for N frames
** And place the N frame addresses into the
** empty Stack array
*/ Initialise();

thread_t tid1, tid2;

threadCreate(&tid1, GetFrame); threadCreate(&tid2, ShowFrame);

sleep(300);

}

GetFrame() {
struct frame *frame; struct frame local;

while (1) {
CameraGrab(&local); /* get a frame from the camera
store it in local */
frame = Pop(); /* pop an empty-frame address from the empty stack */
CopyFrame(&local, frame); /* copy data from the local
frame to the frame address */
Enqueue(frame); /* push the frame address to
} the display queue */
}

ShowFrame() {
struct frame *frame; struct frame local; struct frame filtered;

while (1) {
frame=Dequeue(); /* pop the leading full frame
from the full queue */ CopyFrame(frame, &local); /* copy data to the local frame */

Push(frame); /* push the frame address to the empty stack */
Solarise(&filtered, &local); /* Modify the image */ VideoDisplay(&filtered); /* display the image */
}
}
This program creates two threads, one calls GetFrame(), which continually grabs frames from a camera, and the other thread calls ShowFrame(), which continually displays the frames (after modi- fication). When the program starts the emptyStack contains the addresses of N empty frames in memory.
The process runs for 5 minutes displaying the contents from the camera.

The procedures Pop() and Push() are maintaining the list of frame addresses on the empty stack. Pop() removes a frame memory address from the empty stack, and Push() adds a memory address to the empty stack.

The procedures Dequeue() and Enqueue() are maintaining the list of frame memory addresses in the display queue in display order. Dequeue() removes the memory address of the next frame to display from the display queue, and Enqueue() adds a memory address to the end of the display queue.

The stack and the queue are the same size, and are large enough to contain all available frame memory addresses.

a. Without including synchronisation code problems will occur.

Discuss what could potentially go wrong?

b. Identify the critical sections in the above pseudo-code.

c. Modify the above pseudo-code using semaphores only, to en- sure that problems will not occur.

Hint: this is a variation on the Producer-Consumer problem and will require similar semaphores.

Reference no: EM132361081

Questions Cloud

Much more difficult to modify : Is it because the kernel is so much more difficult to modify? Or, do you think Windows' popularity makes it a better target?
First amendment perhaps playing a role : For example, do see the First Amendment perhaps playing a role here?
Accept input of the name of the grocery item purchased : Using the update function to update the dictionary entry which contains the name, number and price entered by the user. Accept input of the name of the grocery
Demonstrate effective communication strategies : Demonstrate effective communication strategies and teamwork in managing the healthcare of individuals, families, aggregates, and communities.
Identify the critical sections in the above pseudo-code : CSC2404 - Operating Systems - University of Southern Queensland - Identify the critical sections in the above pseudo-code and Without including synchronisation
Create an annotated bibliography for your references : Create an annotated bibliography for your references. Each reference must include approximately 100-150 words describing why it is useful (or not).
Describe one barrier that you feel prohibits nurses : Think about nursing practice and describe one barrier that you feel prohibits nurses from engaging in EBP; share one strategy you could use to facilitate.
Describe the historical aviation activity at the airport : AVM 3201 Aviation Planning Assignment, FIorida Institute of Technology, USA. Describe the historical aviation activity at the airport
What nursing certifications are you considering : In what professional nursing organizations do you currently participate? What organizations might you think about participating in for the future?

Reviews

len2361081

8/26/2019 3:41:35 AM

To be assured of receiving a passing grade a student must obtain at least 50% of the total weighted marks available for the course (i.e. the Primary Hurdle), and have satisfied the Secondary Hurdle (Supervised), i.e. the end of semester examination by achieving at least 40% of the marks available for that assessment item. Supplementary assessment may be offered where a student has undertaken all of the required summative assessment items and has passed the Primary Hurdle but failed to satisfy the Secondary Hurdle (Supervised), or has satisfied the Secondary Hurdle (Super- vised) but failed to achieve a passing Final Grade by 5% or less of the total weighted Marks.

len2361081

8/26/2019 3:41:22 AM

This assignment consists of 4 questions, each of equal value. Please answer the questions in your own words. At most, you should only require about a page to answer each question. It is vitally important that your assignment is clearly laid out with questions and parts of questions clearly defined. It must be a straight forward matter for the examiner to determine that you have completed each exercise satisfactorily. We want quality not quantity. Poorly organised submissions will be rejected or receive a poor mark. A PDF/A document typeset using vanilla LATEX is preferred over a document produced by a word-processor. If you must use Microsoft Word or LibreOffice please export your document as PDF/A1 not PDF.

Write a Review

Operating System Questions & Answers

  Whenever a computer is idle

Whenever a computer is idle, we can either put it in stand by (where DRAM is still active) or we can let it hibernate. Assume that, to hibernate

  Identify the costs associated with security requirement

A year after your 1st visit to credit union the manager calls you once again. His business is experiencing tremendous growth and requires to either open another branch office.

  Design virtual memory system for new operating system

You are asked to design the virtual memory system for a new operating system working on small mobile devices. The memory operates at 333 MHz with a word size of 4 bytes.

  Discuss and provide examples of mutual exclusion

Discuss and provide examples of the following concurrency issues associated with an OS: 1. Mutual exclusion 2. Deadlock 3. Starvation

  Discuss considerations for implementing an operating system

Discuss the considerations for implementing an operating and database system. Recommend the optimum system, considering the types of revenue and expense transactions for this company.

  Question about virus defense

Discuss how can an individual machine get infected with the virus you are researching and how does it spread to other equipments?

  In working out your responses to the discussion question

in working out your responses to the discussion question you should choose examples from your own experience or find

  Explain the role of antennas in transmission

Explain the role of antennas in transmission of radio waves. Determine what type of antenna is typically used in a wireless LAN?

  Identify sources you use when training a CSIRT

Using a web browser, identify at least five sources you would want to use when training a CSIRT. Computerized Operating Systems (OS) are almost everywhere.

  Threads in a multi-threaded process

What components of program state are shared across threads in a multi-threaded process? Can someone provide the answer with reference to operating system?

  Explanation of it networks

While there are difficult security concerns in any isolated computing environment, addition of a network in geographically distributed facilities.

  About your first experience with computer

Please tell us about your home, your interests, your goals, and your educational experience. Then, tell us about your first experience with a computer.

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