+1-415-315-9853

info@mywordsolution.com

## Computer Science

 Algorithms Design Computer Network & Security Automata & Computation Operating System Computer Architecture Information Technology Internet Programming Software Engineering Data Communication Computer Graphics Compiler Design LINUX/UNIX Data Structure WINDOWS Application Digital Circuit E-Commerce Microprocessor Artificial Intelligence Data Warehouse Cryptography

1. Synchronization within monitors uses condition variables and two special operation wait and signal. A more general form of synchronization will be to have a single primitive, waituntil, which had an arbitrary boolean predicate as the parameter. Therefore, one can say, such as waituntil x < 0 or y+z < n. The signal primitive will no longer be required. This scheme is clearly more general, but it is not used. Why not? Hint, think about the implementation.

2. Assume there are 2 threads T1, T2. Please describe if the following solution provides the correct synchronization for critical section which satisfies three conditions:  mutual exclusion, bounded wait and make progress.
T1                                                                          T2
Shared: int t1Inside = 0, t2Inside = 0;                       while (1) {
while (1) {                                                             while (t1Inside);
while (t2Inside);                                                     t2Inside = 2;
t1Inside = 1;                                                         // critical section
// critical section                                                         t2Inside = 0;
t1Inside = 0;                                                           }

3. Please prepare the pseudo code for the following problems:

1. Consider a pizza store which has 10 seats. A customer comes to buy pizza. If there is any unsold pizza left in the kitchen, he could get it immediately. If not, (s)he  needs to wait for chef to make one. After the customer gets the pizza, (s)he will grab a seat and start eating. If there is no seat, (s)he needs to wait. When (s)he finishes eating, (s)h would left the store. The chef in the kitchen just keeps making pizza. Though, (s)he stops if there are 5 unsold pizza left in the kitchen. If a customer come to buy one, (s)he resumes the work to make new pizza. Please prepare pseudo code for both customer and chef using semaphore to solve this problem, and synchronize chef and customers.

Programming Problem:

4. prepare a multi-threaded program to solve producer and consumer problem.

• There are two types of worker thread: producer and consumer. A producer thread  randomly generate an integer between 0-100 (You could use random()/srandom()  or drand48()/srand48() to generate random number in C), and put it into the buffer. A consumer thread simple take the first integer from the buffer. A circular array must be used for the buffer. You don’t need loop for both types of thread. Each thread would exit after only consuming or producing one item (only once).

• Suppose total number of worker thread is 20, and buffer size is 10. Your program must randomly generate the number of producers and consumers. Their relationship must be : num_producers + num_consumers = num_threads, num_producer - num_consumer <= buffer_size, num_consumer <= num_producer, so that no thread will be blocked forever.  The order between consumer and producer threads must be arbitrary. Such as, you will not generate all producers(consumers) and then all consumers (producers).

• Synchronize the producer and consumer.

• You could select any type of language (e.g. C/C++/Java) to execute this program. Your output will look like the following:
Number of producer: 12 Number of consumer: 8
Thread 0 produce 63 in buffer 0, current number of items is 1
Thread 1 consume item 63 in buffer 0, current number of items is 0
Thread 3 produce 45 in buffer 1, current number of items is 1
Thread 5 produce 88 in buffer 2, current number of items is 2
Thread 4 consume item 45 in buffer 1, current number of items is 0
…....
…..
…...
There are still 4 items left in the buffer: 96,26,52,81

• Please submit all source code and a simple readme file on how to compile your code and the sample output. Please zip all files into a single zip file and submit through blackboard.

Operating System, Computer Science

• Category:- Operating System
• Reference No.:- M91317

Have any Question?

## Related Questions in Operating System

### Unikernelas part of the big picture of kernel design take a

UNIKERNEL As part of the big picture of kernel design, take a look at the attached article. In this course, we have not yet covered some of the OS components that are integral to discussing the benefits and detriments of ...

### Operating system assignmentpart onetopic- operating system

Operating System Assignment Part One Topic- Operating system support for mobile computing Submission Rquirements Project Proposal 1 page 1- Pages - 8 to 10 2- Power point slides 3-The project description document which e ...

### Scripting the gnulinux shell1 write a script that stores

Scripting the GNU/Linux Shell 1. Write a script that stores the time it takes a command (your choice of command) to run in three variables, real, user, and system, corresponding to the three default times that time print ...

### Operating systems assignmentprocessor schedulingprocessor

Operating Systems Assignment Processor Scheduling Processor scheduling is aimed to assign processes to be executed by the processor (or processors) in order to achieve certain operating system objectives, such as respons ...

### V1 file processing commands worksheetmiddot

Version 1 File Processing Commands Worksheet · What UID and PID have the highest amount of physical memory a process has used and is not swapped out? Show all processes and full output. · If using a long listing and no p ...

### Operating systems assignmentwe have just 3 processes p1 p2

Operating Systems Assignment We have just 3 processes, P1, P2 and P3, and they arrive at 1, 15 and 23 milliseconds respectively, and they each have two CPU Burst as follows (there are no I/O Bursts). P1: 10 3 P2: 5 12 P3 ...

### Questionwhen designing a kernel with rudimentary

Question: When designing a kernel with rudimentary functionality, what are the required services? Justify your answer and provide an example. provide atleast 15 lines. do the best. need reference which is good.

### 1 from this book you have learned a little about the

1. From this book, you have learned a little about the different file systems inWindows and Linux. To get a better handle on the differences between them, write a short memo describing three properties of each of these f ...

Please address the following: Provide ONE advantage or ONE disadvantage of a Microkernel OS Design or a Monolithic OS Design. Provide support (back up your claims) for your view. The following are examples with proper ju ...

### As the system administrator you are always looking for ways

As the system administrator, you are always looking for ways to improve your network. Although there are many different types of operating systems, there are many versions of the operating systems, as well. After much re ...

• 13,132 Experts

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

### WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

### Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

### Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

### Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

### Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro