Hello Norman,
What if I should kill the thread which hangs in some unknown state? Eg it try to read smart card which was forcibly removed? Any mechanism to isolate consequences? This is a real life example for kind of embedded devices…
Alexander
19 сент. 2025 г., в 13:41, Norman Feske norman.feske@genode-labs.com написал(а):
Hello Rumen,
as you discovered, the thread capability is merely a low-level mechanism. It should normally not be used directly.
Is there a function similar to the one above that will work for Linux?
To kill a thread, destruct the 'Thread` object. Without precautions, however, this brutal method may still have unwelcome side effects as the killed thread may be in an intermediate state like holding a lock. A thread killing itself is a no-go because its execution might crease mid-way during its destruction, provoking inconsistencies like a missing release of the thread's stack.
It is best to have a clear notion of ownership. The one thread who creates another thread should be the one destroying it.
For the destruction, it is advisable to implement a clean wind-down procedure (e.g., the to-be-killed thread signals its owner that it is ready to be destructed) and let the owner call 'Thread::join' before destructing the 'Thread' object.
Cheers Norman
-- Dr.-Ing. Norman Feske Genode Labs
https://www.genode-labs.com · https://genode.org
Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth
users mailing list -- users@lists.genode.org To unsubscribe send an email to users-leave@lists.genode.org Archived at https://lists.genode.org/mailman3/hyperkitty/list/users@lists.genode.org/mes...