Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1152 → Rev 1151

/uspace/trunk/libc/generic/futex.c
38,7 → 38,7
* Because of non-atomic nature of operations performed sequentially on the futex
* counter and the futex wait queue, there is a race condition:
*
* (wq->missed_wakeups == 1) && (futex->count = 1)
* wq->missed_wakeups == 1 && futex->count = 1
*
* Scenario 1 (wait queue timeout vs. futex_up()):
* 1. assume wq->missed_wakeups == 0 && futex->count == -1
154,7 → 154,7
*
* @param futex Futex.
*
* @return ENOENT if there is no such virtual address. Otherwise zero.
* @return ENOENT if there is no such virtual address or futex. Otherwise zero.
*/
int futex_up(atomic_t *futex)
{
/uspace/trunk/init/init.c
39,7 → 39,7
int a;
atomic_t ftx;
 
int __thread stage;
int __thread tls_prom;
 
extern void utest(void *arg);
void utest(void *arg)
257,17 → 257,16
 
static int ptest(void *arg)
{
stage = 1;
printf("Pseudo thread stage%d.\n", stage);
stage++;
tls_prom = -1;
printf("Pseudo thread stage%d.\n", -tls_prom);
tls_prom = -2;
psthread_schedule_next();
printf("Pseudo thread stage%d.\n", stage);
stage++;
printf("Pseudo thread stage%d.\n", -tls_prom);
tls_prom = -3;
psthread_schedule_next();
printf("Pseudo thread stage%d.\n", stage);
printf("Pseudo thread stage%d\n", -tls_prom);
psthread_schedule_next();
stage++;
printf("Pseudo thread stage%d.\n", stage);
printf("Pseudo thread stage4.\n");
psthread_schedule_next();
printf("Pseudo thread exiting.\n");
return 0;
296,7 → 295,7
 
if (futex_down(&ftx) < 0)
printf("Futex failed.\n");
 
/*
if ((tid = thread_create(utest, NULL, "utest")) != -1) {
printf("Created thread tid=%d\n", tid);
}
304,7 → 303,7
if ((tid = thread_create(utest, NULL, "utest")) != -1) {
printf("Created thread tid=%d\n", tid);
}
 
*/
int i;
for (i = 0; i < 50000000; i++)
314,16 → 313,16
printf("Futex failed.\n");
 
 
printf("Creating pseudo thread.\n");
stage = 1;
printf("Creating pathread\n");
tls_prom = 1;
ptid = psthread_create(ptest, NULL);
printf("Main thread stage%d.\n", stage);
stage++;
printf("Main thread stage%d\n",tls_prom);
tls_prom = 2;
psthread_schedule_next();;
printf("Main thread stage%d.\n", stage);
stage++;
printf("Main thread stage%d\n", tls_prom);
tls_prom = 3;
psthread_schedule_next();;
printf("Main thread stage%d.\n", stage);
printf("Main thread stage%d\n", tls_prom);
 
psthread_join(ptid);