There seems to have been some confusion about this on assignment 1,
and rather than just refer everyone to K&R I'll try to explain it.
C declarations are read from right to left:
char *a;
means "a is a pointer to char".
Thus if you write
volatile struct thread *lock_holder;
as many people did, you're saying that lock_holder is a pointer to a
volatile struct thread. In the case of the lock, however, the
volatility of the thread structures is unimportant; what you're
concerned with is the value of the pointer. So what you probably meant
is this:
struct thread *volatile lock_holder;
which means that lock_holder is a volatile pointer to an (ordinary)
struct thread.
(The same syntax applies to "const".)
--
- David A. Holland / dholland(a)eecs.harvard.edu
Show replies by date