Assignment 03
Assignment 03
POSIX shared memory is organized using memory-mapped files, which associate the region of shared
memory with a file.
A process must first create a shared-memory object using the shm_open() system call.
Once the object is established, the ftruncate() function is used to configure the size of the object in bytes.
Finally, the mmap() function establishes a memory-mapped file containing the shared-memory object. It
also returns a pointer to the memory-mapped file that is used for accessing the shared-memory object.
A process uses shm_unlink() function to remove the shared-memory segment after it has accessed the
segment.
Assignment:
2. Write a program which creates a shared memory and writes “Department of IT” in that shared memory.
3. Write a program where two processes (a producer and a consumer) share a shared memory. The
producer process writes the first ten positive integers in the shared memory. The consumer process reads
those integers and prints their sum.