[NSWI004] Questions

Vojtech Horky horky at d3s.mff.cuni.cz
Fri Nov 6 19:34:34 CET 2020


Hello.

Dne 06. 11. 20 v 16:53 Petr Tuma napsal(a):
>> 3) "EINVAL" Invalid thread
>> Can you please define 'Invalid thread'? We have some thoughts about 
>> this one, but we want to know for sure.
> 
> This would normally be returned by functions where the `thread` argument 
> is a handle, as a reaction to getting an invalid handle. When the 
> `thread` argument is a pointer `thread_t *`, you cannot easily recognize 
> whether it is invalid, but there are some opportunities when this could 
> happen - for example, you might record in the `thread_t` structure 
> whether the thread is running and return `EINVAL` when it is not, or you 
> might add a magic number to the thread structure and check it, and so on.
> 
> The presence of `EINVAL` among the permitted return codes does _not_ 
> mean you would have to detect calls to the functions with invalid thread 
> pointers (this is an internal kernel API and pointers used as arguments 
> are therefore typically trusted).
> 
> Maybe Vojtech or Lubomir will chime in with the original intent here.

Exactly. We do not impose any specific situation where this value *has* 
to be returned - the tests also do not check for this value anywhere.

One situation when it can be useful are your own tests checking some 
corner cases, for example. But if you do not use it at all, it is also fine.

Cheers,
- VH



More information about the NSWI004 mailing list