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

Explain segmentation hardware?, Explain segmentation hardware? We defin...

Explain segmentation hardware? We define an completion to map two-dimensional user-defined addresses into one-dimensional physical addresses. This mapping is affected by means

Deadlock resoloution technique, justify the role played by the operating sy...

justify the role played by the operating system in managing the process to avoid deadlock

Deadlock, what are the overall concepts of deadlock

what are the overall concepts of deadlock

Explain about time sharing systems, Q. Explain about Time Sharing Systems? ...

Q. Explain about Time Sharing Systems? Time Sharing Systems Multi-programmed batched systems provide an environment where various system resources (for illustration CP

Activities of an operating system, Q. What are the five main activities of ...

Q. What are the five main activities of an operating system in regard to process management? Answer: a. The creation as well as deletion of both user and system processes

Briefly discuss on real-time scheduling, Briefly discuss on real-time sched...

Briefly discuss on real-time scheduling? It is divided into two types.  Hard real-time systems are needed to complete a critical task within a guaranteed amount of time. T

Comparison of disk scheduling algorithms, COMPARISON OF DISK SCHEDULING ALG...

COMPARISON OF DISK SCHEDULING ALGORITHMS Name      Description                  Remarks      (Selection according to requestor)   RSS        Random scheduling     fo

Explian reference string, What is reference string We evaluate an algor...

What is reference string We evaluate an algorithm by running it on a definite string of memory reference and computing the number of page faults. The string of memory reference

Semaphores, how do semaphores help us in eliminating deadlock conditions?

how do semaphores help us in eliminating deadlock conditions?

Explain activities of an os in regard to file management, What are the five...

What are the five major activities of an operating system in regard to file management? The creation and deletion of files The creation and deletion of directories The s

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