Quote:
Originally Posted by
Corona688
What's controlling the critical section, if not a mutex?
You could try implementing a reader-writer lock if threads do a lot more reading than writing, otherwise, a mutex is about as good.
I am using Lamport's bakery algorithm to control all threads since I need no starvation.
---------- Post updated at 10:13 AM ---------- Previous update was at 10:00 AM ----------
Quote:
Originally Posted by
Loic Domaigne
Good evening,
my answer might sound a bit harsh, but you still don't describe what is the original problem you want to solve. Rather you're describing which technical solution you came with to sort your problem out, which involves 15 threads and 5-6 shared variables per threads, where a variable might be an array of 100 or more elements. And this particular solution leads to a further problem, namely how to sanely synchronize this mess.
Of course, we could give you idea how to tackle the synchronization problem generated by your technical solution. But we might be even more efficient in providing guidance to the initial problem you're trying to solve. For instance, do you want to serve several requests coming e.g. from different TCP clients concurrently? Or you need to perform different processing on a piece of data in a pipeline fashion? ...
Do you understand my point?
Cheers,
Loïc
Hi,
I have TCP connection from clients and the handler also require or read/write some shared variables, but my main pointer is:
Each thread or critical section in the threading should share same time, since the system is time sensitive and it requires to control some hardware, if a critical section costs 100ms and others may delay (since I am using a bit critical section packaged a thread).
The basic requirement about my problem is:
Each critical section or read/write section should share more or less the same time (that means starvation is very bad to me, therefore, I use Lamport's bakery algorithm to control each critical section and make no starving.
And then, I am try to use read/write lock instead of critical section since critical section included a lot of coding, now the time of each critical section doesn't fair.
But I think, If a cut a big critical section (in my case) into different pieces of read/write locks, the starving and waiting time may increase and starving may occur.