6 #include <exec/types.h>
9 #include <proto/exec.h>
19 struct Task
*this = FindTask(NULL
);
20 Wait(SIGBREAKF_CTRL_C
);
21 int *counter
= this->tc_UserData
;
23 struct Library
*aroscbase
;
25 aroscbase
= OpenLibrary("arosc.library", 0);
29 for(i
= 0; i
< ITERATIONS
; i
++)
31 int fd
= open(tmpname
, 0);
32 if(!flock(fd
, LOCK_EX
))
37 printf("\rprogress: %.2f%%", *counter
* 100.0 / (NPROCS
* ITERATIONS
));
48 CloseLibrary(aroscbase
);
56 tmpname
= mktemp("T:flockXXXXXX");
57 int fd
= open(tmpname
, O_CREAT
);
60 TEST((flock(fd
, LOCK_SH
|LOCK_NB
) == 0));
61 TEST((flock(fd
, LOCK_UN
) == 0));
63 TEST((flock(fd
, LOCK_EX
|LOCK_NB
) == 0));
64 TEST((flock(fd
, LOCK_UN
) == 0));
66 TEST((flock(fd
, LOCK_SH
) == 0));
67 TEST((flock(fd
, LOCK_UN
) == 0));
69 TEST((flock(fd
, LOCK_EX
) == 0));
70 TEST((flock(fd
, LOCK_UN
) == 0));
72 /* Create NPROCS processes increasing counter ITERATIONS times in an ugly
75 struct Process
*procs
[NPROCS
];
77 struct TagItem tags
[] =
79 { NP_Entry
, (IPTR
) entry
},
80 { NP_Name
, (IPTR
) "flocker" },
81 { NP_Output
, (IPTR
) Output() },
82 { NP_CloseOutput
, (IPTR
) FALSE
},
83 { NP_UserData
, (IPTR
) &counter
},
84 { NP_NotifyOnDeath
, (IPTR
) TRUE
},
89 for(i
= 0; i
< NPROCS
; i
++)
91 procs
[i
] = CreateNewProc(tags
);
93 ids
[i
] = GetETask(procs
[i
])->et_UniqueID
;
94 Signal((struct Task
*)procs
[i
], SIGBREAKF_CTRL_C
);
97 for(i
= 0; i
< NPROCS
; i
++)
104 TEST((counter
== NPROCS
* ITERATIONS
));