0% found this document useful (0 votes)
2 views1 page

Assignment 03

The document outlines an assignment focused on Inter-Process Communication (IPC) using POSIX shared memory. It details the steps for creating and managing shared memory objects using system calls such as shm_open, ftruncate, mmap, and shm_unlink. The assignment includes tasks to read relevant man pages and write programs for writing to shared memory and implementing a producer-consumer model.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Assignment 03

The document outlines an assignment focused on Inter-Process Communication (IPC) using POSIX shared memory. It details the steps for creating and managing shared memory objects using system calls such as shm_open, ftruncate, mmap, and shm_unlink. The assignment includes tasks to read relevant man pages and write programs for writing to shared memory and implementing a producer-consumer model.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment 3

Operating System Lab


IPC Using Shared Memory:

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:

1. Read the man pages of shm_open, ftruncate, mmap and shm_unlink.

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.

You might also like