next up previous
Next: About this document ... Up: week7 Previous: The OpenMP Programming Model


Assignment:

Write a program to illustrate that errors may arise from incorrect assumptions on relative execution times of threads. (Do only 1 question)
  1. Say, a thread T1 creates another thread T2. T2 requires some data from thread T1. This data is transferred using a global memory location. However, thread T1 places the data in the location after creating thread T2. The implicit assumption here is that T1 will not be switched until it blocks; or that T2 will get to the point at which it uses the data only after T1 has stored it there. Such assumptions may lead to errors since it is possible that T1 gets switched as soon as it creates T2. In such a situation, T1 will receive uninitialized data.
  2. Assume, as before, that thread T1 creates T2 and that it needs to pass data to thread T2 which resides on its stack. It passes this data by passing a pointer to the stack location to thread T2. Consider the scenario in which T1 runs to completion before T2 gets scheduled. In this case, the stack frame is released and some other thread may overwrite the space pointed to formerly by the stack frame. In this case, what thread T2 reads from the location may be invalid data. Similar problems may exist with global variables.

next up previous
Next: About this document ... Up: week7 Previous: The OpenMP Programming Model
Cem Ozdogan 2006-11-15