What are race conditions?, Operating System

Assignment Help:

What are race conditions?

Race conditions are problems that take place due to the sharing of the same file by several processes. In such a case none of the processes is able to use the shared file. Consider the illustration of a printing queue that maintains the list of all files to be printed. As well consider a file shared by two processes PA and PB.

1266_What are race conditions.png

The file has obtained two variables:

                    ‘in’ pointing to the next free slot (N.F.S)                     

and

          ‘out’ pointing to the next job to be executed.       

    

   Primarily in the file, in=7 and out=4. Let PA be the first process that uses the file. Then PA sets its local variable N.F.S=7. However before placing into the queue, an interrupt occurs. At present PB comes. PB also sets its local variable N.F.S=7 and is placed in the queue.

Then N.F.S=N.F.S+1 which sets in=8. In such a case while implementing PA overwrites the slot 7 that is already occupied by PB. Thus nothing will be printed. Such a condition is an example for race condition.

 

The file has obtained two variables:

                        'in' pointing to the next free slot (N.F.S)                     

and

          'out' pointing to the next job to be executed.     

 

Primarily in the file, in=7 and out=4. Let PA be the first process that uses the file. Then PA sets its local variable N.F.S=7. However before placing into the queue, an interrupt occurs. At present PB comes. PB also sets its local variable N.F.S=7 and is placed in the queue.

Then N.F.S=N.F.S+1 which sets in=8. In such a case while implementing PA overwrites the slot 7 that is already occupied by PB. Thus nothing will be printed. Such a condition is an example for race condition.


Related Discussions:- What are race conditions?

Explain linked allocation, Linked allocation With linked allocation, ev...

Linked allocation With linked allocation, every file is a linked list of disk blocks; the disk blocks might be scattered anywhere on the disk. The directory has a pointer to th

Major locking errors, When programming with threads, there are three very c...

When programming with threads, there are three very common mistakes that programmers often make: 1. locking twice (depending on the system and type of lock, can cause crashes, h

Long term scheduler, Long term scheduler calculates which processes are a...

Long term scheduler calculates which processes are admitted to the machine for processing. It accepts the degree of multiprogramming. Once accepted, a job converts a process.

Define multithreading, Define multithreading The proficiency of an oper...

Define multithreading The proficiency of an operating system to execute different parts of a program called threads simultaneously is called as multithreading. A thread is a fl

Describe the differences among short-term and medium-term, Describe the dif...

Describe the differences among short-term, medium-term, and long-term scheduling.   Short-term (CPU scheduler)-selects from jobs in memory those jobs that are ready to execu

Replacement algorithm for tlb, Consider the following C program where M, N,...

Consider the following C program where M, N, K are predefined constants. Assume int is 4 bytes. Suppose this program is run on a machine with 4KB page size and 32 TLB entries. Init

Determine what the expansion of nested macro calls follows, Determine what ...

Determine what the expansion of nested macro calls follows  The expansion of nested macro calls follows the Last in First out (LIFO) rule.

Action taken by the operating system when a page fault occur, Q. Under what...

Q. Under what conditions do page faults occur? Explain the actions taken by the operating system when a page fault occurs. Answer: A page fault take places when an access to

Explain enhanced second-chance algorithm, Enhanced second-chance algorithm....

Enhanced second-chance algorithm. When we increase the second-chance algorithm by considering both the reference bit and the modify bit as an order pair. We have the following

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd