projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add comment to clarify behavior.
[pintos-anon]
/
grading
/
threads
/
alarm-single.c
diff --git
a/grading/threads/alarm-single.c
b/grading/threads/alarm-single.c
index fabf420aabedbbf78650df030c90b63d799e124d..8acef92209075527852d4696c97100204f6fa93a 100644
(file)
--- a/
grading/threads/alarm-single.c
+++ b/
grading/threads/alarm-single.c
@@
-33,8
+33,8
@@
struct sleep_thread_data
tid_t tid; /* Thread ID. */
int id; /* Sleeper ID. */
tid_t tid; /* Thread ID. */
int id; /* Sleeper ID. */
- struct lock *lock; /* Lock on access to `o
ut
'. */
- int **o
ut; /* Output buffer
. */
+ struct lock *lock; /* Lock on access to `o
p
'. */
+ int **o
p; /* Output buffer position
. */
};
static void sleeper (void *);
};
static void sleeper (void *);
@@
-77,7
+77,7
@@
test_sleep (int iterations)
t->id = i;
t->lock = &lock;
t->id = i;
t->lock = &lock;
- t->o
ut
= &op;
+ t->o
p
= &op;
}
/* Wait for all the threads to finish. */
}
/* Wait for all the threads to finish. */
@@
-109,7
+109,7
@@
test_sleep (int iterations)
t->id, product, new_prod);
}
t->id, product, new_prod);
}
- printf ("...done\n"
, output
);
+ printf ("...done\n");
}
static void
}
static void
@@
-120,20
+120,13
@@
sleeper (void *t_)
for (i = 1; i <= t->iterations; i++)
{
for (i = 1; i <= t->iterations; i++)
{
- int old_product;
- int new_product = i * t->duration;
-
- timer_sleep ((t->start + new_product) - timer_ticks ());
+ timer_sleep ((t->start + i * t->duration) - timer_ticks ());
lock_acquire (t->lock);
lock_acquire (t->lock);
- *
t->op
++ = t->id;
+ *
(*t->op)
++ = t->id;
lock_release (t->lock);
}
lock_release (t->lock);
}
- lock_acquire (t->lock);
- *t->op++ = t->id;
- lock_release (t->lock);
-
/* Signal completion. */
sema_up (&t->done);
}
/* Signal completion. */
sema_up (&t->done);
}