[ECOS] ecos questions:kill safty
Nick Garnett
nickg@calivar.demon.co.uk
Wed Jun 26 20:23:00 GMT 2002
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
More information about the Ecos-discuss
mailing list