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

What is thrashing, What is thrashing? It is a method in virtual memory...

What is thrashing? It is a method in virtual memory schemes when the processor spends most of its time swapping pages, rather than implementing instructions. This is because o

Distinguish among pcs and scs scheduling, Q. Distinguish among PCS and SCS ...

Q. Distinguish among PCS and SCS scheduling. Answer: PCS scheduling is completed local to the process. It is how a thread library schedules threads onto available LWPs. SCS sch

Explain the different multithreading models, Question 1: a) Briefly exp...

Question 1: a) Briefly explain each of the following terms: (i) Distributed systems. (ii) Real time systems. (iii) Multiprocessor. b) What is the impo

Galvin, difference between process and thread

difference between process and thread

What is meant by the phrase thread-safe, The term thread-safe in computer p...

The term thread-safe in computer programming describes that routine or portion of the program that may be called from multiple programming threads without uncalled for interactions

Computers, What is operating system?

What is operating system?

Define the term system software, Question: (a) Define the term system ...

Question: (a) Define the term system software and application software, giving an example for each. (b) Draw a diagram to represent the abstract view of a computer system i

What are the various file operations, What are the various file operations?...

What are the various file operations? The six basic file operations are Creating a file Reading a file Writing a file Repositioning within a file Tr

Permanently starves cpu-bound programs, Q. Presume that a scheduling algori...

Q. Presume that a scheduling algorithm at the level of short-term CPU scheduling favours those processes that have used the least processor time in the recent past. Why this algori

Explain acyclic-graph directories, Acyclic-graph directories An acyclic...

Acyclic-graph directories An acyclic graph permits directories to have shared subdirectories and files. The similar file or subdirectory may be in two dissimilar directories. A

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