Re: question about mutexes in TS

2018-10-10 Thread Walt Karas
But these are not inherently purposes. I could decide there needed to be a special thread to execute all functions with the letter r in the name. But that would arbitrary, not an actual purpose. Generally speaking, in an event driven system, you only need different threads for multiple cores and

Re: question about mutexes in TS

2018-10-10 Thread Pushkar Pradhan
I thought the purpose of the different threads in ATS was pretty clear. There are many threads to handle requests (1.5x the number of HT cores). 8 threads to handle disk I/O (cache). 2-3 threads to do miscellaneous tasks. 2-3 threads to handle logging. One thread for each port which you want to lis

Re: question about mutexes in TS

2018-10-10 Thread Walt Karas
Unfortunately that's like many of our explanations, too open-ended to be very helpful when someone sits down to write some code. On Wed, Oct 10, 2018 at 2:26 PM Alan Carroll wrote: > > To accomodate different behavior requirements on the continuations > scheduled on a thread in that pool. E.g. non

Re: question about mutexes in TS

2018-10-10 Thread Alan Carroll
To accomodate different behavior requirements on the continuations scheduled on a thread in that pool. E.g. non-blocking vs. blocking for one. On Wed, Oct 10, 2018 at 2:25 PM Walt Karas wrote: > Why do we need thread pools? > On Wed, Oct 10, 2018 at 2:17 PM Alan Carroll > wrote: > > > > Yes, th

Re: question about mutexes in TS

2018-10-10 Thread Walt Karas
Why do we need thread pools? On Wed, Oct 10, 2018 at 2:17 PM Alan Carroll wrote: > > Yes, that's not well developed. However, it is the reason TS mutexes are > shareable. If there is a resource shared between continuations the TS > approach is to have those continuations share the same mutex leadi

Re: question about mutexes in TS

2018-10-10 Thread Alan Carroll
Yes, that's not well developed. However, it is the reason TS mutexes are shareable. If there is a resource shared between continuations the TS approach is to have those continuations share the same mutex leading to natural rescheduling for lock contention. In addition, that TS mutexes are recusive

Re: question about mutexes in TS

2018-10-10 Thread Walt Karas
On Wed, Oct 10, 2018 at 1:35 PM Leif Hedstrom wrote: > > > > > On Oct 10, 2018, at 11:31 AM, Walt Karas wrote: > > > > It seems like ATS does not have a coherent strategy for threading and > > mutexes. > > > > One pure strategy is event driven with one thread per core (processing > > an event qu

Re: question about mutexes in TS

2018-10-10 Thread Leif Hedstrom
> On Oct 10, 2018, at 11:31 AM, Walt Karas wrote: > > It seems like ATS does not have a coherent strategy for threading and mutexes. > > One pure strategy is event driven with one thread per core (processing > an event queue). Share data structures are owned by a particular core > (also help

Re: question about mutexes in TS

2018-10-10 Thread Walt Karas
It seems like ATS does not have a coherent strategy for threading and mutexes. One pure strategy is event driven with one thread per core (processing an event queue). Share data structures are owned by a particular core (also helps with NUMA), and events that want to access the data structure are

Re: question about mutexes in TS

2018-10-10 Thread Pushkar Pradhan
I think Alan is referring to the below code. It's a try lock, so if it doesn't succeed it's just rescheduled for later. void EThread::process_event(Event *e, int calling_code) { ink_assert((!e->in_the_prot_queue && !e->in_the_priority_queue)); MUTEX_TRY_LOCK_FOR(lock, e->mutex, this, e->contin

Re: question about mutexes in TS

2018-10-09 Thread Alan Carroll
By explicit continuation locking, I mean code like your example - before(); TSMutexLock(mutex); critical_section(); TSMutexUnlock(mutex); after(); The call to TSMutexLock() is an explicit lock of the mutex. It address the issue by noting that it rarely, if ever, comes up. However what you suggest

Re: question about mutexes in TS

2018-10-09 Thread Walt Karas
To what "explicit continuation locking" do you refer? How does this address the issue that using TSMutexLock() or MutexLock in a currently running continuation function (unnecessarily) blocks all other events waiting in a thread event queue? Whereas the inability to lock a continuation mutex caus

Re: question about mutexes in TS

2018-10-09 Thread Leif Hedstrom
> On Oct 9, 2018, at 2:44 PM, Alan Carroll > wrote: > > It's a bit more complex than that. One key thing is that if you schedule an > event for a continuation, when the event handler is called the continuation > mutex will be locked. Therefore it's rarely the case a plugin needs to lock > its

Re: question about mutexes in TS

2018-10-09 Thread Alan Carroll
It's a bit more complex than that. One key thing is that if you schedule an event for a continuation, when the event handler is called the continuation mutex will be locked. Therefore it's rarely the case a plugin needs to lock its continuations explicitly. For that reason, simply scheduling handle

question about mutexes in TS

2018-10-09 Thread Walt Karas
In TS, is it important to favor use of continuation mutexes to avoid thread blocking. For example, should code like this: before(); TSMutexLock(mutex); critical_section(); TSMutexUnlock(mutex); after(); be replaced with code like: int contf_after(TSCont, TSEvent, void *) { after(); return