Discussion:
Syscall error codes other than -1
(too old to reply)
Daniel Ramsbrock
2005-10-13 20:23:10 UTC
Permalink
The syscall table in the spec says to return -1 for all of the error
conditions, but semtest2 only tests for < 0. I assume it's OK to return
meaningful error codes defined in errno.h? For example, if P() is called
on an invalid (non-existing) semaphore, it would make sense to return
EINVALID (-12) rather than -1 (which is defined as EUNSPECIFIED).

Along those same lines, I assume it's also OK to define our own error
codes. For example, I defined two: one when Create_Semaphore is called
while the max semaphore count is reached and one for the case where
P(sem) and V(sem) are called by a process which did not previously
create the semaphore sem--but sem exists because another process has
created it (to me, this is a separate error from calling P() or V() on a
semaphore which doesn't exist).

Let me know if these assumptions are OK. I know it's a picky detail, but
I want to make sure I stick to the specs.

Thanks,

Daniel
Michael Hicks
2005-10-14 18:33:33 UTC
Permalink
The tests in the grading criteria are exactly the tests we use to grade,
so if it works for them, it works for us. :)

Seriously, any negative value is a legal error code (is that an
oxymoron?) so feel free to define your own errnos.

-Dr. Hicks

Loading...