Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Write 3 programs. Two of the programs would be producer process which write
the value of temperature (at every 3 second) and pressure( every 3 second)
respectively into a shared memory segment with 2 locations ( One for temperature of float data type and one for pressure of double data type). The third process would be a consumer process which would consume and display the current pressure and temperature at every 3 seconds.

What I have tried:

C++
#include <stdio.h>
void main()
{
     int tmp;

	printf("Input days temperature : ");
	scanf("%d",&tmp);
	if(tmp<0)
		printf("Freezing weather.\n");
   else if(tmp<10)
		printf("Very cold weather.\n");
	else if(tmp<20)
		printf("Cold weather.\n");
	else if(tmp<30)
		printf("Normal in temp.\n");
	else if(tmp<40)
		printf("Its Hot.\n");
	else
		printf("Its very hot.\n");
}
Posted
Updated 19-Nov-22 16:17pm
v3

1 solution

This is your homework/assignment. Google Search will find many of the answers for you... Learn to use it as a research tool. I'll get you started...

c shared memory between processes - Google Search[^] - the very first search result has answers for you: How to use shared memory with Linux in C[^] ... there are many other solutions available...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900