Start learning 50% faster. Sign in now
A semaphore is a synchronization mechanism that is crucial for controlling access to shared resources in a multithreaded environment. It serves as a signaling mechanism that can be used to prevent race conditions, which occur when multiple threads attempt to modify shared data simultaneously, leading to unpredictable outcomes. Semaphores maintain a count of available resources and ensure that only a certain number of threads can access the critical section of code at any given time. When a thread wants to enter a critical section, it checks the semaphore's value; if it is greater than zero, the thread decrements it and proceeds; otherwise, it is blocked until the semaphore is released by another thread. This prevents multiple threads from executing critical sections concurrently, thereby eliminating race conditions and ensuring data consistency. Option B (Fork) - Fork is used to create new processes, not for synchronizing access to shared resources. Option C (Signal) - Signals are used for inter-process communication but do not provide the same level of resource control as semaphores. Option D (Context Switch) - Context switching refers to the operating system's ability to switch between processes and threads, which does not inherently prevent race conditions. Option E (Stack) - A stack is a data structure and does not serve any synchronization purpose in multithreading.
A sum of ₹10,000 is invested in two schemes A and B. Scheme A offers 10% per annum and scheme B offers 15% per annum. If the total interest earned aft...
The average weight of 12 children rises by 2.15 kg after one of the children, who weighs 56 kg, is replaced by a new child. What is the weight of the ne...
Two tangents are drawn from an external point to a circle with radius 8 cm, and the distance between the external point and the center of the circle is ...
The highest common factor (HCF) of two numbers is 17. If their product is 867, how many pairs of numbers satisfy these conditions...
A can complete a piece of work in 12 days, B in 18 days, and C in 36 days. They all work together for a few days, after which A leaves. B and C continue...
Two poles are 30 meters and 50 meters high, and the distance between their bases is 20√3 meters. Find the angle of elevation of the top of the taller ...
115, 138, 163, 190, 219, ?
If Aman and Bhanu together earn Rs. ___ per month, and their incomes increase by 25% and 12.5% respectively, Bhanu's new income b...