Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

Comp604 Operating System|Producer And Assessment Answer

Task 1: The Buffer (or Buffer.java)
Internally, the buffer will consist of a fixed-size array of type buffer_item (which will be defined using a typedef). The array of buffer_item objects will be manipulated as a circular queue. The definition of buffer_item, along with the size of the buffer, can be stored in a Java class file or C header file such as the following:
Example snippet of buffer.h or constant.java file
  /* buffer.h */              // Java: constant.java   typedef int buffer_item;       // Java: omit it in Java or use                                   //       wrapper class
  #define BUFFER_SIZE 5;       // Java: public static final                                   //       int BUFFER_SIZE = 5
 
The buffer will be manipulated with two functions, insert_item() and remove_item(), which are called by the producer and consumer threads, respectively. A skeleton outlining these functions appears as:
Example snippet of buffer.c or buffer.java file
#include <buffer.h> //Java: import  
/* the buffer */
 
buffer_item buffer[BUFFER_SIZE];
 
int insert_item(buffer_item item) {
/* insert item into buffer return 0 if successful, otherwise
return -1 indicating an error condition */

int remove_item(buffer_item *item) {
 
/* remove an object from buffer  return 0 if successful, otherwise
return -1 indicating an error condition */
}
 
The insert_item() and remove_item() functions will synchronize the producer and consumer using the algorithms outlined in the lecture slides. The buffer will also require an initialization code section (which is part of the main() function) that initializes the empty, full, and mutex semaphores.
      
Task 2: The main() Function (or Main.java)
 
The main() function will initialize the buffer and create the separate producer and consumer threads. Once it has created the producer and consumer threads, the main () function will sleep for a period of time and, upon awakening, will terminate the application. The main () function will be passed three parameters on the command line:
1.How long to sleep before terminating
2.The number of producer threads
3.The number of consumer threads A skeleton for this function appears as:
Example snippet of buffer.c or Main.java file
#include <buffer.h>
int main(int argc, char *argv[]) { //Java: public static void                                    //     main(String[] args)
/* 1. Get command line arguments argv[1], argv[2], argv[3]*/ 
/* 2. Initialize buffer */
/* 3. Create producer threads */
/* 4. Create consumer threads */
/* 5. Sleep */
/* 6. Exit */
 
 
Task 3: Producer and Consumer Threads (or Producer.java and Consumer.java)
 
The producer thread will alternate between sleeping for a random period of time (1ms to maximum 1000 ms) and inserting a random integer into the buffer. Random numbers will be produced using the rand()function, which produces random integers between 0 and RAND_MAX (Java: Math.random()). The consumer will also sleep for a random period of time (1ms to maximum 1000 ms) and, upon awakening, will attempt to remove an item from the buffer.
Please print the following for both consumer and producer threads




Buy Comp604 Operating System|Producer And Assessment Answers Online


Talk to our expert to get the help with Comp604 Operating System|Producer And Assessment Answers to complete your assessment on time and boost your grades now

The main aim/motive of the management assignment help services is to get connect with a greater number of students, and effectively help, and support them in getting completing their assignments the students also get find this a wonderful opportunity where they could effectively learn more about their topics, as the experts also have the best team members with them in which all the members effectively support each other to get complete their diploma assignments. They complete the assessments of the students in an appropriate manner and deliver them back to the students before the due date of the assignment so that the students could timely submit this, and can score higher marks. The experts of the assignment help services at urgenthomework.com are so much skilled, capable, talented, and experienced in their field of programming homework help writing assignments, so, for this, they can effectively write the best economics assignment help services.

Get Online Support for Comp604 Operating System|Producer And Assessment Answer Assignment Help Online

Resources

    • 24 x 7 Availability.
    • Trained and Certified Experts.
    • Deadline Guaranteed.
    • Plagiarism Free.
    • Privacy Guaranteed.
    • Free download.
    • Online help for all project.
    • Homework Help Services
); }
Copyright © 2009-2023 UrgentHomework.com, All right reserved.