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
Define Enforcing Modularity for C Additionally, in C it is sometimes necessary to create modularity of design. C++  is very natural model for component based application design

Q. Give the reasons why Windows XP, Solaris and Linux implement multiple locking mechanisms. Explain the circumstances under which they use mutexes, spinlocks, semaphores, adaptiv

Q. How Program execute in operating system? Program execution- The operating system fills the contents (or sections) of a file into memory as well as begins its execution. A us

Priority Scheduling leads to the risk of starvation: a process is ready, but never is given the processor. Some preemptive priority schedulers therefore reserve a fraction of the p

What are the use of job queues, ready queues and device queues? As a process enters a system they are put in to a job queue. These queues having of all jobs in the system. The

Q. What are the advantages as well as disadvantages of using circuit switching? For what types of applications is circuit switching a viable strategy? Answer: Circuit

1. Problem Domain You will be considering the Wumpus world introduced in Russell and Norvig (2009) Chapter 7. For this programming assignment you'll use Prolog's ability to do in

Your CTO liked your proposal from Unit 2 so much he only trusts you to explain complex concepts to his managers. He now wants you to write him a four page paper explaining the CPU,

Problem 1. What is kernel? What are the main components of a kernel? Defining Kernel Explaining Main components of Kernel 2. What is mutual exclusion? What are i

Recognition of essential syntactic constructs by reductions, this task is carried out by Recognition of essential syntactic constructs by reductions, this task is carried out