Question

Check the file: Questions.pdf

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

// thread to simulate lab biologyst
void LabBiologist(void *param)
{
cout << "Lab biologyst thread started.\n";
while (thread1Active) // works while the field biologyst is active
{
while (!memoryAvailable) // check if the memory is free, if not wait 30ms and try again
{
cout << "Lab biologyst thread: waiting for memory to be free.\n";
Sleep(30);
}
memoryAvailable = false; // lock the memory for lab biologyst thread
if (animals.size() > 0) // if there are animals in the vector, print them
{
cout << "reading following animals:\n";
for (vector<Carnivora*>::iterator it = animals.begin(); it != animals.end(); it++)
{
Carnivora* c;
c = *it;
c->PrintValues();
}
}
memoryAvailable = true; // release the memory
Sleep(100); // wait 100ms
}
cout << "Lab biologist thread ended.\n";
thread2Active = false;
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Tip Amount Program
Homework Solution
$30.00
Computer
Science
C
Language
Tip
Amount
Program
Pseudo
Code
Restaurant
Charge
Taxes
Percentage
C++ Classes For Card Game
Homework Solution
$20.00
Programming
C++
Computer Science
Coding
Classes
OOP
Functions
Methods
Variables
Statements
Constructor
Random Numbers
Inheritance
Card Games
C++ Problems
Homework Solution
$25.00
Programming
C++
Computer Science
Console Applications
Codes
Classifications
Students
Adults
Seniors
Subway
Customers
Fee Categories
Integers
Statements
Variables
Loops
Indexes
Average Values
Minimum
Maximum
Arrays
Functions
Input
Ou
Get help from a qualified tutor
Live Chats