Data races, critical sections, processor loading, Operating System

Research the phenomenon of data races. Give an example of how an unprotected data race can give rise to data inconsistency. How do OpenMP and Cilk resolve this problem?

Data race is that situation or condition in which multiple threads, without intervening synchronization, try to access the same memory location, with at least one thread performing a write operation. For eg. many data races occur on numerical algorithms owing to chaotic relaxation and asynchronous iterative methods. Also, there are systems where synchronized threads or processes maintain probabilities with best-estimate-matrix and may race with one other to provide updates.This is usually described in higher-level language specs by the phrase: "undefined behavior." A data race could legitimately reprogram the BIOS delete data from the disk and may also stop the processor's fan leading to a multi-core meltdown. 

example code:

 

int checker = 0;

int counts = 0;

Lock lock;

 

bool TryEnter() {

    if (checker == /* get thread id */) {

        counts += 1;

        return true;

    }

 

    if (lock.TryEnter()) {

        checker = /* get thread id */;

        return true;

    }

    return false;

}

 

void Exit() {

    if (counts != 0) {

        counts -= 1;

        return;

    }

    checker = 0;

    lock.Exit();

}

 

the compiler or the processor may “optimize” this program as:

 

void Exit() {

    if (counts != 0) {

        counts -= 1;

        return;

    }

    checker = 42;

    checker = 0;

    lock.Exit();

} 

The effect of this is perhaps not observable in the current thread, nor is it observable by other threads in the absence of data races. Here, the unfortunate thread whose ID is 42 might observe this value and take the ignite the mistake. 

OpenMP and Cilk resolve data racing through a technique known as Data parallelism.It focuses on distributing the data across different parallel computing nodes. This is achieved when each processor performs the same task on different pieces of distributed data. In some situations, a single execution thread controls operations on all pieces of data. In others, individual threads control the operation, but they execute the same code.

Posted Date: 6/29/2012 2:09:57 AM | Location : United States







Related Discussions:- Data races, critical sections, processor loading, Assignment Help, Ask Question on Data races, critical sections, processor loading, Get Answer, Expert's Help, Data races, critical sections, processor loading Discussions

Write discussion on Data races, critical sections, processor loading
Your posts are moderated
Related Questions
Research the phenomenon of data races. Give an example of how an unprotected data race can give rise to data inconsistency. How do OpenMP and Cilk resolve this problem? Data

Q. An operating system sustains a paged virtual memory using a central processor with a cycle time of 1 microsecond. It costs an additional one microsecond to access a page other

What is the purpose of the command interpreter? Why is it usually separate from the kernel? It reads commands from the user or from a file of commands and executes them, usuall

Write a note on deadlocks. The proper definition of deadlock A set of processes is deadlocked if every process in the set is waiting for an event that only a proces

Questiion 1 What is RTOS? What are its requirements? Questiion 2 Explain the structural elements of a real time system mode Questiion 3 What is kernel? Explain abo

Question: (a) i. Consider Active Directory as a database, then for each type and new class of objects, what is created? ii. What is the purpose of the global catalog? ii

We have stressed the need for an operating system to make efficient use of the computing hardware. When is it appropriate for the operating system to forsake this principle and to

Concept of Reentrancy   It is a useful, memory-saving method for multiprogrammed timesharing machines. A Reentrant method is one in which multiple clients can share a singl

Define thrashing. Thrashing is the accident of high page traffic and low CPU utilization. It is observed that the cause of thrashing is an under-commitment of memory to program

What does it mean for something to be thread-safe? By saying that X is thread-safe, we mean that if multiple threads use X at the same time, we don't have to worry about concurrenc