Found 640 Articles for Computer Science

Dining Philosophers Problem (DPP)

Kristi Castro
Updated on 24-Jun-2020 12:16:40
The dining philosophers problem states that there are 5 philosophers sharing a circular table and they eat and think alternatively. There is a bowl of rice for each of the philosophers and 5 chopsticks. A philosopher needs both their right and left chopstick to eat. A hungry philosopher may only eat if there are both chopsticks available.Otherwise a philosopher puts down their chopstick and begin thinking again.The dining philosopher is a classic synchronization problem as it demonstrates a large class of concurrency control problems.Solution of Dining Philosophers ProblemA solution of the Dining Philosophers Problem is to use a semaphore to ... Read More

Producer Consumer Problem using Semaphores

Alex Onsman
Updated on 24-Jun-2020 12:17:41
The producer consumer problem is a synchronization problem. There is a fixed size buffer and the producer produces items and enters them into the buffer. The consumer removes the items from the buffer and consumes them.A producer should not produce items into the buffer when the consumer is consuming an item from the buffer and vice versa. So the buffer should only be accessed by the producer or consumer at a time.The producer consumer problem can be resolved using semaphores. The codes for the producer and consumer process are given as follows −Producer ProcessThe code that defines the producer process ... Read More

Readers-Writers Problem

Ricky Barnes
Updated on 24-Jun-2020 12:18:26
The readers-writers problem relates to an object such as a file that is shared between multiple processes. Some of these processes are readers i.e. they only want to read the data from the object and some of the processes are writers i.e. they want to write into the object.The readers-writers problem is used to manage synchronization so that there are no problems with the object data. For example - If two readers access the object at the same time there is no problem. However if two writers or a reader and writer access the object at the same time, there ... Read More

Process Synchronization in Linux

Kristi Castro
Updated on 24-Jun-2020 12:19:48
Process synchronization in Linux involves providing a time slice for each process so that they get the required time for execution.The process can be created using the fork() command in Linux. The creating process is called the parent process and the created process is the child process. A child process can have only one parent but a parent process may have many children. Both the parent and child processes have the same memory image, open files and environment strings. However, they have distinct address spaces.A diagram that demonstrates the fork() command is given as follows −Orphan ProcessesThere are some processes ... Read More

Remote Procedure Call (RPC)

Alex Onsman
Updated on 24-Jun-2020 12:21:28
A remote procedure call is an interprocess communication technique that is used for client-server based applications. It is also known as a subroutine call or a function call.A client has a request message that the RPC translates and sends to the server. This request may be a procedure or a function call to a remote server. When the server receives the request, it sends the required response back to the client. The client is blocked while the server is processing the call and only resumed execution after the server is finished.The sequence of events in a remote procedure call are ... Read More

Operating Systems Client/Server Communication

Ricky Barnes
Updated on 24-Jun-2020 12:22:35
Client/Server communication involves two components, namely a client and a server. They are usually multiple clients in communication with a single server. The clients send requests to the server and the server responds to the client requests.There are three main methods to client/server communication. These are given as follows −SocketsSockets facilitate communication between two processes on the same machine or different machines. They are used in a client/server framework and consist of the IP address and port number. Many application protocols use sockets for data connection and data transfer between a client and a server.Socket communication is quite low-level as ... Read More

Major issues with Multi-threaded Programs

Kristi Castro
Updated on 31-Jan-2020 10:24:32
Multithreaded programs allow the execution of multiple parts of a program at the same time. These parts are known as threads and are lightweight processes available within the process.Threads improve the application performance using parallelism. They share information like data segment, code segment files etc. with their peer threads while they contain their own registers, stack, counter etc.Some of the issues with multithreaded programs are as follows −Let us see them one by one −Increased Complexity − Multithreaded processes are quite complicated. Coding for these can only be handled by expert programmers.Complications due to Concurrency − It is difficult to ... Read More

Single-threaded and Multi-threaded Processes

David Meador
Updated on 31-Jan-2020 10:30:07
Single threaded processes contain the execution of instructions in a single sequence. In other words, one command is processes at a time.The opposite of single threaded processes are multithreaded processes. These processes allow the execution of multiple parts of a program at the same time. These are lightweight processes available within the process.Multithreaded Processes ImplementationMultithreaded processes can be implemented as user-level threads or kernel-level threads. Details about these are provided using the following diagram −User-level ThreadsThe user-level threads are implemented by users and the kernel is not aware of the existence of these threads. It handles them as if they ... Read More

Methods for Handling Deadlocks

Kristi Castro
Updated on 24-Jun-2020 12:06:06
Deadlock detection, deadlock prevention and deadlock avoidance are the main methods for handling deadlocks. Details about these are given as follows −Deadlock DetectionDeadlock can be detected by the resource scheduler as it keeps track of all the resources that are allocated to different processes. After a deadlock is detected, it can be handed using the given methods −All the processes that are involved in the deadlock are terminated. This approach is not that useful as all the progress made by the processes is destroyed.Resources can be preempted from some processes and given to others until the deadlock situation is resolved.Deadlock ... Read More

Deadlock Characterization

Alex Onsman
Updated on 24-Jun-2020 12:07:09
A deadlock happens in operating system when two or more processes need some resource to complete their execution that is held by the other process.A deadlock occurs if the four Coffman conditions hold true. But these conditions are not mutually exclusive. They are given as follows −Mutual ExclusionThere should be a resource that can only be held by one process at a time. In the diagram below, there is a single instance of Resource 1 and it is held by Process 1 only.Hold and WaitA process can hold multiple resources and still request more resources from other processes which are ... Read More