Lock revenue variable, Operating System

Assignment Help:

Demonstrate that your program (include the program output as part of the final report) can produce the correct output with the following parameters. For each case comment if the output agree with the given parameters.

Case a. factory_delay=1, retail_delay=2, warehouse_delay=3, max_product=2 and max_revenue=4.


Case b. factory_delay=2, retail_delay=1, warehouse_delay=3, max_product=3 and max_revenue=4.

Case c. factory_delay=1, retail_delay=3, warehouse_delay=2, max_product=3 and max_revenue=6.

Factory thread:
 
    printf("Factory thread starting.\n");
 
   while (1){
   
     // lock revenue variable and test for termination conditon
     if (revenue>=max_revenue){
  break;
  }
   
     if ((product0)){
       product++;
       parts--;
    revenue--;

         printf("Factory: manufacturing. | Parts=%d | Products=%d | Revenue=%d|\n",parts,product,revenue);
     }
     else{
       if (product>=max_products)
         printf("Factory: stock overflow! | Parts=%d | Products=%d | Revenue=%d |\n",parts,product,revenue);      
       else if (parts<1)
         printf("Factory: no parts! | Parts=%d | Products=%d | Revenue=%d |\n",parts,product,revenue);      
     }   
       
     // delay the thread according to factory_delay
     Sleep(factory_delay*1000);
   }
 
    printf("Factory thread terminating.\n");


Related Discussions:- Lock revenue variable

Show the services which provided by operating system, Q. Show the services ...

Q. Show the services which provided by operating system? A) Resource Allocation: If there are more than one user or jobs running at the same instance then resource

Independent process, what is independent process? distinguished between ind...

what is independent process? distinguished between independent process and co-operating process

Explain concept of buffering, Buffering Messages exchanged by communica...

Buffering Messages exchanged by communication processes reside in a impermanent queue. Such a queue can be executed in three ways. Zero capacity: The queue length is 0.

Define a program that is in execution is known as, Define a program in exec...

Define a program in execution is known as A program in execution is known as a process

Cache replacement policies, The physical memory acts as a cache backed by t...

The physical memory acts as a cache backed by the disk. When the physical memory is full, and we want to read in another page from disk, we have to evict a page from physical memor

Give an overview of windows 2000 file management, Give an overview of WINDO...

Give an overview of WINDOWS 2000 file management. Windows makes use of the NTFS and File Allocation Table file systems. The Older versions of the FAT file system had file name

What is logical address space and physical address space, What is logical a...

What is logical address space and physical address space? The set of all logical addresses formed by a program is known as a logical address space; the set of all physical addr

What are the different directory structures, What are the different directo...

What are the different directory structures? Explain each type. There are five dissimilar directory structures: 1.      Single level directory 2.      Two level directory

Single-level page tables, As mentioned above, page tables, are lookup table...

As mentioned above, page tables, are lookup tables mapping a process' virtual pages to physical pages in RAM. How would one implement these page tables? The most straightforward

Why is it complicated to protect a system, Q. Why is it complicated to prot...

Q. Why is it complicated to protect a system in which users are allowed to do their own I/O? Answer: In earlier chapters we identified a distinction among kernel and user mod

Write Your Message!

Captcha
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