Question

in 5-6 sentences 1) What is a race condition? Provide an example. 2) What do we...

in 5-6 sentences


1) What is a race condition? Provide an example.


2) What do we mean by a critical section of code?


3) What do we mean by process or thread synchronization?


0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans 1 : A race condition is a problem that occurs when a system attempts to perform two or more operations at the same time, but because of the nature of the system, the operations must be done in the proper sequence to be done correctly.

Race condition example :

i) b=4

ii) b=b-2

iii) d=b+1

If the above operations executed in the proper sequence then d=3 ,but if the iii operation executed before ii then d = 5 .

Ans 2: Critical section of code is a code segment in which if there are group of coordinating processes then at a given point of time, only one process must be executing its critical section. If any other process also wants to execute its critical section, it must wait until the first one finishes its execution. There are solution to critical section problem :

a) Mutual Exclusion : Only one process can be in its critical section at a given point of time.

b) Progress :If no process is in its critical section and there are thread available then any one thread can enter the critical section and finishes its execution .

c) Bounded Waiting: After a process makes a request for getting into its critical section, there is a limit for how many other processes can get into their critical section, before this process's request is granted. So after the limit is reached, system must grant the process permission to get into its critical section.

Ans 3:Thread synchronization is defined as a mechanism which ensures that two or more concurrent processes or threads do not simultaneously execute some particular program segment known as critical section. Processes' access to critical section is controlled by using synchronization techniques.

For example, suppose that there are three processes, namely A, B, and C. All three of them are concurrently executing, and they need to share a common resource (critical section) . Synchronization should be used here to avoid any conflicts for accessing this shared resource. Hence, when Process A and B both try to access that resource, it should be assigned to only one process at a time. If it is assigned to Process A, the other process (Process B) needs to wait until Process A frees that resource.

Add a comment
Know the answer?
Add Answer to:
in 5-6 sentences 1) What is a race condition? Provide an example. 2) What do we...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 7:21 * WMPA fter 13 & 14 Evaluatic 1. Define Process Evaluation[1-2 sentences]: b. Give 1...

    7:21 * WMPA fter 13 & 14 Evaluatic 1. Define Process Evaluation[1-2 sentences]: b. Give 1 example of Process Evaluation [1-2 sentences]: 2. Define Impact Evaluation [2-3 sentences]: b. Give 1 example of Impact Evaluation [1-2 sentences]: Start Thread & 7:22 9OWMPA + DB# 3: Chapter 13... b. Give 1 example of Impact Evaluation [1-2 sentences]: 3. You have been hired by the Department of Health to evaluate a health education program that aims to reduce STIs in South Bronx...

  • What do we mean by an allocation that is dynamically efficient? explain in 5- 7 sentences.

    What do we mean by an allocation that is dynamically efficient? explain in 5- 7 sentences.

  • TRUE-FALSE     Basic synchronization principles and multithreading 1. Java user threads can implement both busy-waiting and no-busy-waiting...

    TRUE-FALSE     Basic synchronization principles and multithreading 1. Java user threads can implement both busy-waiting and no-busy-waiting policy. 2. Priority inversion avoids deadlocks. 3. Spinlock mutex can be used as an adaptive mutex. 4. Java RTE can be blocked for Input/Output operation. 5. Interrupted user thread, which executes a method in a monitor, must be rolled back to undo any changes it performed. 6. The synchronization primitive by disabling interrupts can be used by an application program. 7. Bounded-waiting requirement is...

  • //In this assignment, we use multiple threads to calculate the sum // 1*1 + 2*2 +...

    //In this assignment, we use multiple threads to calculate the sum // 1*1 + 2*2 + 3*3 + 4*4 + ... + n*n // Note we should know from CSE2500 that this sum is // n*(n+1)*(2*n+1)/6 // We a n value, we will create 2*n threads to do the calculation so that // we can have a race condition. // Before you change the code, read the code and run the code and see what // happens. Do we already...

  • Synchronization, race condition, etc. Which of the choices are correct? Consider the code below in Java,...

    Synchronization, race condition, etc. Which of the choices are correct? Consider the code below in Java, corresponding to the implementation of a list using an array: public class MyArrayList private int[] array- new int [MAX_SIZE]; private AtomicInteger size-new AtomicInteger() public void insert(int element) do int position - size.get); array[position] - element; 3 while (!size.compareAndSet(position, position + 1)); Assume that the list is initially empty, and that two threads call insert simultaneously, one with parameter 5, and one with parameter 9....

  • a. What is the difference between culture, race, and ethnicity? Write 3-5 sentences about the difference....

    a. What is the difference between culture, race, and ethnicity? Write 3-5 sentences about the difference. 2. b. Please post a level 1 and a level 2 question (with the questions focused on cultural inquiry) on your topic. Level 1 is basic info (ex. Who are Jehovah Witnesses?) Level 2 examines your health topic in relation to the cultural group.

  • Section 1: Educational Background (2-4 sentences) Educational history, What do you like about school? What have...

    Section 1: Educational Background (2-4 sentences) Educational history, What do you like about school? What have you found to be challenging? Section 2: Professional Background (4-6 sentences) Job/Career history What have you liked about your jobs? • What kind of job/career do you hope to obtain with your degree? Section 3: Personal Interests (2-4 sentences) What do you like to do with your spare time? What kinds of books/movies do you enjoy? • Where have you travelled in your lifetime...

  • *) (5) What is referred to as a "self-locking” power screw and what is the condition...

    *) (5) What is referred to as a "self-locking” power screw and what is the condition for it! b) (4) What are the two main mechanisms for "thread loosening" in a threaded connection? c) (2) If fatigue is of concer, what manufacturing process should be adopted for the bolt (Heat Treat/Roll or Roll/Heat Treat)? d) (5) Preload control (correct preload and its maintenance) is critical in maintaining a threaded connection's integrity. List the five most important factors affecting the preload...

  • Give an example of a business model in 2 to 5 sentences. (Do not u something...

    Give an example of a business model in 2 to 5 sentences. (Do not u something similar is fine. Try to challenge yourselft) 4. se the example I used in class -but a. Create a Cost function and a Revenue function that models this business situation. b. Show your calculations to find the profit function here c. Graph your Cost and Revenue functions and label what the intersection represents. d. Discuss when you will start making a profit and how...

  • 1. What is Critical thinking? Please give an example of Critical thinking. 2. What is Clinical...

    1. What is Critical thinking? Please give an example of Critical thinking. 2. What is Clinical reasoning? Please give an example of Clinical reasoning. 3. Differentiate Critical thinking and Clinical reasoning. 4. Why does a nurse must have both Critical thinking and Clinical reasoning? Explain 5. What are the techniques of critical thinking? What are the components of Clinical reasoning? 6. Why is Critical thinking and Clinical reasoning necessary in Nursing Process?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT