5 #include <exec/types.h>
8 #include <proto/exec.h>
18 struct Task
*this = FindTask(NULL
);
19 Wait(SIGBREAKF_CTRL_C
);
20 int *counter
= this->tc_UserData
;
22 struct Library
*aroscbase
;
24 aroscbase
= OpenLibrary("arosc.library", 0);
28 for(i
= 0; i
< ITERATIONS
; i
++)
30 int fd
= open(tmpname
, 0);
31 if(!flock(fd
, LOCK_EX
))
36 printf("\rprogress: %.2f%%", *counter
* 100.0 / (NPROCS
* ITERATIONS
));
47 CloseLibrary(aroscbase
);
55 tmpname
= mktemp("T:flockXXXXXX");
56 int fd
= open(tmpname
, O_CREAT
);
59 TEST((flock(fd
, LOCK_SH
|LOCK_NB
) == 0));
60 TEST((flock(fd
, LOCK_UN
) == 0));
62 TEST((flock(fd
, LOCK_EX
|LOCK_NB
) == 0));
63 TEST((flock(fd
, LOCK_UN
) == 0));
65 TEST((flock(fd
, LOCK_SH
) == 0));
66 TEST((flock(fd
, LOCK_UN
) == 0));
68 TEST((flock(fd
, LOCK_EX
) == 0));
69 TEST((flock(fd
, LOCK_UN
) == 0));
71 /* Create NPROCS processes increasing counter ITERATIONS times in an ugly
74 struct Process
*procs
[NPROCS
];
76 struct TagItem tags
[] =
78 { NP_Entry
, (IPTR
) entry
},
79 { NP_Name
, (IPTR
) "flocker" },
80 { NP_Output
, (IPTR
) Output() },
81 { NP_CloseOutput
, (IPTR
) FALSE
},
82 { NP_UserData
, (IPTR
) &counter
},
83 { NP_NotifyOnDeath
, (IPTR
) TRUE
},
88 for(i
= 0; i
< NPROCS
; i
++)
90 procs
[i
] = CreateNewProc(tags
);
92 ids
[i
] = GetETask(procs
[i
])->et_UniqueID
;
93 Signal(procs
[i
], SIGBREAKF_CTRL_C
);
96 for(i
= 0; i
< NPROCS
; i
++)
103 TEST((counter
== NPROCS
* ITERATIONS
));