🔍
1 like 0 dislike

1 Answer

Shared memory :

For sharing of data faster and communication between programs, we use shared memory. Shared memory can be used with multiprocessors and single processors. Means Program can be run on the single processor and multiple processors the memory used for communication between threads of the program is called shared memory. In the shared memory system, the single processor has the access to the same memory and also if there are multiple processors they also have the access to same memory. If the applications are developed for shared memory they can share data by using same memory location. Shared memory is the method of Inter-Process Communication (IPC). Shared memory is faster than message queue.

Shared memory has two types:

1.Uniform memory access

2.Non-uniform memory access

The shared data should be protected otherwise it will cause shared data problems.


Mutex:

The mutex is the key to the shared resource. The mutex is the program object which is used for sharing the same resource among multiple program thread. The shared resource cannot be used by multiple threads so for locking the shared resource we use the mutex. If the shared resource is lock by mutex then the thread will go into the queue and when the shared resource is unlocked by mutex then the shared resource is used by another thread. Mutex provide mutual exclusion. A mutex does not allow the access to shared resource simultaneously.

There are two basic operations of mutex:

1. LOCK(mutex)

2. UNLOCK(mutex)

The mutex lock the shared resource when it is used by the thread and unlock the shared resource when the task finishes.


Message passing:

Message passing is the method of interprocess communication (IPC). Message passing is slower than shared memory. Message passing is used in parallel programming and object orientated programming. Message passing can be synchronous or message passing can be asynchronous.

Deadlock:

Deadlock is a problem where threads or processes are in waiting state and waiting for each other to unlock or to release the shared resource. Means thread is waiting for the next thread to unlock while the next thread is waiting for the first thread to unlock for execution, So both stops progressing execution and result in deadlock process. By rebooting or resetting the entire system we can end the deadlock.

Deadlock may be caused due to:

1. Mutual exclusion

2. Hold and wait

3. No resource preemption

4. Circular wait

If the four conditions occur simultaneously then the deadlock occurs.

0 like 0 dislike

Related questions

Explain the advantages and disadvantages of using memory I/O and standard I/O.
Answer : Memory mapped I/O and standard I/O are the two methods for communicating microprocessor with peripherals. Processor talks to both memory and peripheral using the same bus.Two ways to talk to a peripheral. ... of standard I/O is no loss of memory addresses to the use as I/O addresses. ...

View solution
0 like 0 dislike
1 answer

Explain memory hierarchy.
Answer : Memory hierarchy: Main memory is large, inexpensive, slow memory stores entire program and data. Cache memory is small, expensive, fast memory stores copy of likely accessed parts of large ... In memory hierarchy the smaller memory is faster and larger memory storage is slower. ...

View solution
0 like 0 dislike
1 answer

Explain memory write ability and storage permanence with suitable diagram.
Answer : Write ability and storage permanence of memories: Write ability is the manner and speed at which memory can be written. Storage permanence is the ability of memory to hold stored bits ... Holds bits after power is no longer supplied. High end and middle range of storage permanence. ...

View solution
0 like 0 dislike
1 answer

EEPROM VS FLASH MEMORY
Answer : EEPROM VS FLASH MEMORY...

View solution
0 like 0 dislike
1 answer

The distributed system is a collection of (P) and communication is achieved in distributed system by (Q) , where (P) and (Q) are : (A) Loosely coupled hardware on tightly ... message passing ,respectively. (D) Loosely coupled software on tightly coupled hardware and file sharing, respectively.
Answer : (C) Tightly coupled software on loosely coupled hardware and message passing ,respectively. ...

View solution
0 like 0 dislike
1 answer

50.5k questions

47.1k answers

240 comments

7.0k users