
- Operating System Tutorial
- OS - Home
- OS - Overview
- OS - Components
- OS - Types
- OS - Services
- OS - Properties
- OS - Processes
- OS - Process Scheduling
- OS - Scheduling algorithms
- OS - Multi-threading
- OS - Memory Management
- OS - Virtual Memory
- OS - I/O Hardware
- OS - I/O Software
- OS - File System
- OS - Security
- OS - Linux
- OS - Exams Questions with Answers
- OS - Exams Questions with Answers
- Operating System Useful Resources
- OS - Quick Guide
- OS - Useful Resources
- OS - Discussion
What is the shared memory concept by using producer consumer problem?
Inter process communication requires communicating to establish a shared memory region. A shared memory region is present in the address space for the process that creates the shared memory segment. And other processes are communicating using a shared memory segment that is attaching it to their address space.
Operating system prevents one process from accessing another process’s memory.
In shared memory two or more processes can exchange information by reading and writing data in shared memory areas. The processes are also responsible for ensuring that they are not writing to save location.
Producer-consumer problem
Now, let us discuss producer-consumer process problems.
Step 1 − A producer process produces information that is consumed by the consumer process. For example, a compiler that produces assembly code which is consumed by an assembler. The assembler can produce object modules which are consumed by the loader.
Step 2 − It uses the shared memory concept.
Step 3 − If we want to allow producer and consumer processes to run concurrently, we have to provide a buffer of items which can be filled by producer and empty the buffer by consumer.
Step 4 − This buffer will reside in a region of memory which is shared by producer and consumer process.
Step 5 − A producer can produce one item while the consumer is consuming another item.
Step 6 − The producer and consumer must be synchronised, so that the consumer does not try to consume an item which is not yet produced.
Types of buffer
There are two types of buffer which are as follows −
Unbounded buffer − It has no limit on the size of the buffer. The consumer may have to wait for new items, but the producer can always produce new items.
Bounder buffer − It assumed a fixed buffer size.
The consumer has to wait if the buffer is empty and the producer must wait if the buffer is full.
Given below is the structure of shared memory system
- Related Articles
- Producer Consumer Problem using Semaphores
- What is shared memory in the OS?
- What is shared-memory model in computer architecture?
- What is shared memory architecture in parallel databases?
- Consumer Memory
- What are Shared Memory MIMD Architectures?
- What are the different shared-memory multiprocessor models?
- IPC through shared memory
- Difference between Consumer Surplus and Producer Surplus
- The Concept of Consumer Gifting Behavior
- Consumer Psychology Concept & Theories
- If a grasshopper is eaten by a frog, then the energy transfer will be from : producer to decomposerproducer to primary consumerprimary consumer to secondary consumersecondary consumer to tertiary consumer
- Shared Memory Model of Process Communication
- Algorithm for implementing Distributed Shared Memory
- What is meant by Consumer Decision-Making?
