Wednesday, May 19, 2010

Thread-safe events

Если Вы пишите многопоточное приложение, то всегда стоит задумываться о потоко-безопасности (thread safe). Сегодня затронем важную тему про то, как правильно возбуждать событие (event raise), доступ к которому осуществляется в нескольких потоках.

Monday, March 15, 2010

Thread-based or event-based

The ongoing discussion of threadlets (or fibrils, or whatever they will be called next week) has considered the addition of a major new API to the kernel. This discussion has, however, studiously ignored an important question: what about the longstanding kevent patch which, at some level, solves the same problems? The motivation for the first fibril patch was to make it easier to provide comprehensive asynchronous I/O in the kernel - and that was one of the reasons for kevents as well. So it has been surprising that kevents have not figured into this conversation.

Thursday, February 18, 2010

Way to pause a thread indefinitely

Never, ever use Thread.Suspend. The major problem with it is that 99% of the time you can't know what that thread is doing when you suspend it. If that thread holds a lock, you make it easier to get into a deadlock situation, etc. Keep in mind that code you are calling may be acquiring/releasing locks behind the scenes. Win32 has a similar API: SuspendThread and ResumeThread. The following docs forSuspendThread give a nice summary of the dangers of the API.