Dailydave mailing list archives

Re: Asynchronous


From: greg hoglund <hoglund666 () gmail com>
Date: Sun, 23 Oct 2011 09:29:43 -0700

There is fairly robust support for concurrent programming on Windows, and
obviously the hardware has evolved to support it.  I encourage everyone to
take the leap – in a way “threads are dead”.  Many old programming models
are simply outdated.  For example, the commonly understood sockets and
select() is like being in the dark ages.  Using IO completion ports (IOCP) I
have been able to get upwards of 50,000 TCP sessions up on a single thread
with a Windows 2003 R2 platform.  Also, spamming threads at a problem isn’t
a good idea either (TMT == too many threads).

Whether you dev or reverse, the concurrent style of programming may drive
you insane.  I would suggest anyone working on the server end of the rope to
explore IO completion ports, the same technology that is used by IIS and MS
SQL server (assuming windows server environment).  If you are on the RE
side, I would suggest you fully understand how spinlocks, mutexes, critical
sections, WaitForSingleObject, etc., work because these are the code
patterns you will have to identify to locate shared objects at a glance.
Dave is right about debugging.  Forget the RE side, even developing can be a
serious pain because concurrent models are difficult as hell to debug.  My
solution has been to code my own debugging and trace routines into a wrapper
around the OS supplied locking logic.  For example, critical sections allow
multiple re-entrant locking on the same thread – something that can come
back and bite you.  So, to create a model where double-locks are denied I
wrap the call and maintain a ref count.  Using the windows debugging API’s I
can stack trace the previous lock and assert on the double, dumping a trace
of where the offending lock lives (just one of many creative ideas to speed
up the hunt for bugs).  So, it’s not impossible to debug but you will find
yourself home-rolling some tools to help.  Also, the tool Parallels from
Intel is a godsend.  I hope this helps.

-Greg
_______________________________________________
Dailydave mailing list
Dailydave () lists immunityinc com
https://lists.immunityinc.com/mailman/listinfo/dailydave

Current thread: