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 scored 20% more than B. If both score 4 marks more than the sum of the marks scored by A and B together would have been 20% more than the passing mar...
A’s income exceeds that of B’s by Rs.2,000 and B’s income is 40% less than that of C’s. If the total income of all of them put t...
Out of 1200 people in a city, 40% speak Mandarin and the rest speak Cantonese. If out of non-Mandarin speakers, 35% are males and out of Mandarin speake...
In an exam, Aman scored 60% marks and failed by 85 marks whereas Raj scored 80% marks in the same exam and scored 65 marks more than the passing marks. ...
Arun saves 30% of his salary while Gagan saves 32%. If both get the same salary and Gagan saves Rs. 1600, find the savings of Arun?
Rohan's salary is 60% lower than Raj's salary. What percentage more is Raj's salary compared to Rohan's salary?
Mr Rajesh buys a toy for Rs 27.50 and sells it for Rs 28.60 Find the gain percentage
In an election, candidate 'A' secured 56% of the total votes cast, while candidate 'B' garnered 85% of the remaining votes. Among the votes received by ...
Monthly income of P is Rs.20000 and his monthly savings is Rs.12000. If his monthly income is decreased by 40% and monthly expenditure is decreased by 3...
Akshita and Monika started a business with initial investments of Rs. 2,400 and Rs. 2,500 respectively. After one year, Akshita withdrew ___% and Monika...