could task dispatching be enabled in libc_delete_hook() ?

Till Straumann strauman at slac.stanford.edu
Fri Nov 12 03:29:52 UTC 2004


Chris Johns wrote:
> Till Straumann wrote:
> 
>>
>> I came across a problem (PR#716) which could be solved easily
>> if task dispatching could temporarily be enabled in the 
>> libc_delete_hook().
>>
>> Could you please give an analysis whether this would be safe?
>>
> 
> I would say no. The delete call is provided with the current thread and 
> if you enable dispatching will current be current when you get back 
> control and disable dispatching. Sure you could look at 
> _Thread_Executing but this is a bit of a hack.
> 
> Another issue is the extensions list order is not controlled so an API 
> may have deleted its user or API extension and another thread may try to 
> do something with the thread via an API.
> 
>>
>> PS: I believe 716 exists independent of my modifications, it just
>> is less obvious (since it would only appear if a task with a unflushed
>> stream other than stdout/stderr is deleted).
>>
> 
> I see the need to make sure all memory allocated to a task is released 
> when the task is closed, and maybe flushing buffers (but no convinced) 
> but closing open files seems to be mixing a process model with a thread 
> model.

Sure - I believe sharing files (among threads)
will come with future newlib versions. However,
in 1.11 it seems that FILE objects are maintained
per-thread :-( hence the need to clean them up...

T.

> 





More information about the users mailing list