Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Environment Your code must compile and execute on Ubuntu 14.04.5 as installed on lab machines and provided as a VirtualBox virtual machine (VM) You are

image text in transcribed

Environment Your code must compile and execute on Ubuntu 14.04.5 as installed on lab machines and provided as a VirtualBox virtual machine (VM) You are encouraged to use the VM with VirtualBox on your own laptop/PC so you are not limited by lab availability. Task 1: Create and destroy a shared memory segment (10 marks) Place your code for this task in a directory named task1 Write a C program in a file named producer.c that 1. Creates a shared memory segment of size 32 bytes. 2. Sleeps for 10 seconds using the sleep function. 3. Destroys the shared memory segment. 4. Exits, returning an appropriate status code. You will need to research the Linux system calls necessary to accomplish this. To get started, refer back to Lab 4 and the shmget function. At each of the steps listed above, print the status of your program to stdout (standard out) using printf. For example $ ./producer -Using key 17102569 -Shared memory segment created with ID 2097152 -Sleeping for 10 seconds... -Shared memory segment destroyed While developing your solution, make use of the ipcs command to list all shared memory segments on the system (i.e., the VM). Until you get segment removal working, the ipcrm command can be used for cleanup; the -m option will remove a shared memory segment with a specific ID. Consult the relevant man pages or links for further information on these commands. ipcs -Shared Memory Segments- shmid 98304 key bytes 32 owner perms nattch $. ipcrm-m 98304 #Removes the segment with id 98304

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions