[NSWI004] clarification about double pointer in a03, create_thread

Vojtech Horky horky at d3s.mff.cuni.cz
Fri Nov 13 15:02:54 CET 2020


Hello,

I am replying via mailing list as this could be interesting to others too.

Dne 13. 11. 20 v 12:42 Nicola Maino napsal(a):
> [...] I was wondering the meaning of 
> the double-pointer for thread_out in the function create_thread in a03.
> The meaning of a pointer to pointer itself is clear, but how can I 
> allocate space for the stack to a pointer that points to a therad_t 
> structure? (in the comment is written that the ** is needed because we 
> should allocate space for both thread and stack)

The pointer to the stack would be part of the thread_t structure, so you 
do not need to return it directly. As a matter of fact, the caller is 
probably not interested in the stack anyway.

The comment about double ** relates to the thread_t parameter only. We 
do not expect that anyone - except thread_create - would allocate 
thread_t structure. User will always only prepare pointer to it (as can 
be seen in the tests such as thread/basic).

Hope this helps,
- VH


More information about the NSWI004 mailing list