12.01.2017 12:10, Alex Peshkoff wrote:
> On 01/12/17 13:00, Vlad Khorsun wrote:
>> 12.01.2017 10:24, Alex Peshkoff wrote:
>>> On 01/11/17 23:35, Vlad Khorsun wrote:
>>>
>>>>>> I do it easily. AST thread is blocked at
>>>>>> Database::Sync::lock on syncMutex.enter() despite of a lot of checkouts 
>>>>>> in worker
>>>>>> thread.
>>>>> Hmm... From posix POV that's a bug but certainly windows calls may have
>>>>> different rules. May be it makes sense to increase thread's priority
>>>>> when it's going to deliver AST?
>>>>        I did it in AstContextHolder - not helps. I see blocked thread with 
>>>> highest priority...
>>>> I plan to try to change syncMutex by Event or Mutex (currently it is 
>>>> Critical Section)
>>>> and see if it helps
>>     Mutex seems to fix the issue
>
> May be Critical Section does not promise fair scheduling?

   Looks like no sync objects promise fair scheduling on Windows

https://msdn.microsoft.com/library/windows/desktop/ms682530.aspx
Critical Section Objects
...
Starting with Windows Server 2003 with Service Pack 1 (SP1), threads waiting on 
a critical
section do not acquire the critical section on a first-come, first-serve basis. 
This change
increases performance significantly for most code. However, some applications 
depend on first-in,
first-out (FIFO) ordering and may perform poorly or not at all on current 
versions of Windows
(for example, applications that have been using critical sections as a 
rate-limiter).
...
Windows Server 2003 and Windows XP:  Threads that are waiting on a critical 
section are added to
a wait queue; they are woken and generally acquire the critical section in the 
order in which they
were added to the queue. However, if threads are added to this queue at a fast 
enough rate, performance
can be degraded because of the time it takes to awaken each waiting thread.


https://msdn.microsoft.com/library/windows/desktop/ms684266.aspx
Mutex Objects
...
If more than one thread is waiting on a mutex, a waiting thread is selected. Do 
not assume a first-in,
first-out (FIFO) order. External events such as kernel-mode APCs can change the 
wait order.


http://joeduffyblog.com/2006/12/14/anticonvoy-locks-in-windows-server-2003-sp1-and-windows-vista/
...
If you remove the strict fairness policy, however, the system scales. And that, 
my friends, is why all
of the locks in Windows are now unfair.


Regards,
Vlad

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to