problem about race condition


 
Thread Tools Search this Thread
Top Forums Programming problem about race condition
# 1  
Old 09-14-2010
problem about race condition

Hi all,
i'm reading Andrew S.Tanenbaum's book --- Modern Operating System.At the part of discussing race condition.And the author gives a solution with using the TSL instruction,say that one process must call the enter_region function before entering the critical regions and call the leave_region after finish hes job,as following:
Code:
enter_region:
       TSL  REGISTER,LOCK
       CMP REGISTER,$0
       JNE enter_region
       RET

leave_region:
      MOVE LOCK,$0
      RET

and i'm ok with that code,but the author gives another similar code and says it is essentially the same as the solution with TSL,code is following:

Code:
enter_region:
       MOVE  REGISTER,$1
       XCHG  REGISTER,LOCK
       CMP    REGISTER,$0
#my question is :
#what if the scheduler choose another process 
#to run now and set the LOCK to 1 and 
#enter the critical region?
       JNE enter_region
       RET

leave_region:
      MOVE LOCK,$0
      RET



---------- Post updated at 04:36 AM ---------- Previous update was at 04:32 AM ----------



---------- Post updated at 04:39 AM ---------- Previous update was at 04:36 AM ----------

sorry I forget now the LOCK is already 1 and no process can enter it.....
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with IF condition .

Hi i am writing a script where i am running , 5 scripts together in 1 script . Now what i want is when these 5 scripts run completely , i should execute some other commands like i have compile the data etc. I have have 5 echo statements at the end of all those scripts . Like echo "1 is done" in... (1 Reply)
Discussion started by: honey26
1 Replies

2. Programming

Race condition with PTY

I've been experimenting with pseudo-terminals and found something I don't quite understand. Writing an EOF character to the master end doesn't work quite as I expect. Once I've written any other data, the master pty seems to treat a single ^D as a seperator, i.e. writing "abcabc" would let cat do... (1 Reply)
Discussion started by: Corona688
1 Replies

3. Programming

In unix how we can test or check race condition in a c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies

4. Programming

In unix how we can test or check race condition in c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (5 Replies)
Discussion started by: afroze
5 Replies

5. UNIX for Dummies Questions & Answers

In unix how we can test or check race condition in a c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies

6. Linux

In unix how we can test or check race condition in c program by using multi threads

In unix how we can test or check race condition in any c program by using multi thread programming (1 Reply)
Discussion started by: afroze
1 Replies

7. Shell Programming and Scripting

race condition with wait() function

Hi, I'm currently writing a bash script, that starts multiple threads: ____________________ #!/bin/bash loop=0 while((loop!=10)) do thread & ((loop++)) done #wait for all sub-processes (thread) to finish wait ___________________ Now I want to know, what happens, if a... (2 Replies)
Discussion started by: tho99
2 Replies
Login or Register to Ask a Question