Does Indy use some kind of cooperative multitasking on XP, and if so, is there a way to switch to other connections?

I have a web server that runs off of Indy's TIdTCPServer component. I have several requests coming in at once that need to be synchronised so each requests gets handled after the previous was sent. This is done using a mutex. On Vista and Win7 this works great but on XP it seems the wait on the mutex also hangs other connections. It times out after 5 seconds so it'll still continue, but my app is very time sensitive.

I assume it goes like this on XP:

Connection 1:

  • Parse request
  • Try to acquire mutex
  • Success
  • Do stuff
  • Reply -> Indy uses this opportunity to switch threads

Connection 2:

  • Parse request
  • Try to acquire mutex
  • Fail with time out
  • Return "sorry, time out" -> Indy switches back to Connection 1

Connection 1:

  • Release mutex

If Indy uses cooperative multitasking like this, I'll have to do something else. Does anyone know if on XP it does use cooperative multitasking?


So, I'm seeing in IdYarn that the yarn is a completely empty object now. Still, the question stands about cooperative multitasking.


Every connection in a TIdTCPServer runs in its own worker thread. The OS, not Indy, controls task switching between threads. If one thread successfully locks the mutex, no other thread can enter the lock until the first thread unlocks it. That is Mutithreaded Programming 101, on any OS version. That behavior is not specific to Indy. What you outlined is how it is supposed to behave. If Vista/Win7 is not behaving that way, then you have a problem.

Need Your Help

Transforming variable density on log scale with R

r scale logarithm

I want to plot the density of variable whose range is the following:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.