라벨이 fast mutex인 게시물 표시

Porting to OS/2: Case #15 fast mutex

Mutex(mutual-exclusive) is used to synchronize executions of threads. Of course, OS/2 supports mutex very well. But, there is one caution. OS/2 mutex is a recursive mutex. That is, if a thread requests a mutex which is already owned by a different thread, that thread is blocked. But if a thread which already owns a mutex requests the same mutex, then it succeeds. This is a recursive mutex. In general, this works well. However, sometimes a non-recursive mutex, so called fast mutex, is needed. That is, even if an owner thread requests its owning mutex, that thread should be blocked, get an error at least. A fast mutex can be implemented easily with a recursive mutex of OS/2. The following are the codes. Colored By Color Scripter ™ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 #define  INCL_DOS #include  ...