hschumann2/TempleOS-Source-Code
0847
1 2/*lock{} is a compiler stmt3which places asm LOCK inst4prefixes on code. Only use it on5read-modify-write stmts.6It will generate invalid insts7if you misuse it and it will crash.8U() to see what code was generated.9*/10 11#define CNT 0x100000012 13I64 glbl;14 15U0 MPUnlockedInc(I64)16{17 I64 i;18 for (i=0;i<CNT;i++)19 glbl++;20}21 22U0 UnlockedInc()23{24 CJob *tmpm0,*tmpm1;25 glbl=0;26 tmpm0=JobQue(&MPUnlockedInc,NULL,0,0);27 tmpm1=JobQue(&MPUnlockedInc,NULL,1,0);28 JobResGet(tmpm0);29 JobResGet(tmpm1);30 "Correct Cnt:%X Actual Cnt:%X\n",CNT*2,glbl;31}32 33U0 MPLockedInc(I64)34{35 I64 i;36 for (i=0;i<CNT;i++)37 lock //Can be used without {}38 glbl++;39}40 41U0 LockedInc()42{43 CJob *tmpm0,*tmpm1;44 glbl=0;45 tmpm0=JobQue(&MPLockedInc,NULL,0,0);46 tmpm1=JobQue(&MPLockedInc,NULL,1,0);47 JobResGet(tmpm0);48 JobResGet(tmpm1);49 "Correct Cnt:%X Actual Cnt:%X\n",CNT*2,glbl;50}51 52UnlockedInc;53LockedInc;54 