This isn't a horribly hard task, we'll need need to add a "semaphor" (I think that's the right term?) to main_struct. Every time a thread beings using the array (read, write, whatever) it increments the field, every time it leaves, it decrements it.
There will also need to be a single bit write lock. When someone wants to delete from the list, they set the write lock and wait for the semaphor to become 0. Any readers or writer will spin on this lock before touching the semaphor. Readers will just spin if it's 1, writers will spin and try and increment it themselves.
The performance impact on anything using the thread_info_list will be fairly serious, but the only thing that uses it is the clean job which has unpredictable performance characteristics anyways because it spins on the safe field.
This isn't a horribly hard task, we'll need need to add a "semaphor" (I think that's the right term?) to
main_struct
. Every time a thread beings using the array (read, write, whatever) it increments the field, every time it leaves, it decrements it.There will also need to be a single bit write lock. When someone wants to delete from the list, they set the write lock and wait for the semaphor to become 0. Any readers or writer will spin on this lock before touching the semaphor. Readers will just spin if it's 1, writers will spin and try and increment it themselves.
The performance impact on anything using the
thread_info_list
will be fairly serious, but the only thing that uses it is theclean
job which has unpredictable performance characteristics anyways because it spins on thesafe
field.