This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ecos questions:kill safty


zhlg_shuhan <zhlg_shuhan@sina.com> writes:

> Hi,all
>    In ecos API suspend(),delete(),kill() etc., when you want to suspend a thread with a mutex owned,ecos suspend the thread simply and do not concern the mutex,I feel this is unsafty!
> the same process occured in delete() etc. 
>  Right?
> 

Strictly this is unsafe, but the alternatives are even worse. The
extra work necessary to track all the synchronization object that a
thread owns would add extra fields to all threads and synchronization
objects and would render some synchronization operations
non-deterministic.

In any case, doing this would not help. If a thread has acquired a
lock, it is in the process of making changes to some data that it does
not want other threads to see. If we just kill it and break the lock
then other threads may see inconsistent data.

The correct approach is for application threads to detect when they
are expected to exit by application specific means. Then they can
clean up in an orderly manner and call cyg_thread_exit().

-- 
Nick Garnett - eCos Kernel Architect


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]