Posts Tagged ‘ Threading

Thread Synchronization: Ensuring Atomic Operations

An atomic operation in computer science refers to a set of operations that can be combined so that they appear to the rest of the system to be a single operation with only two possible outcomes: success or failure (Wikipedia).

In a threaded application certain variables or objects may be shared by multiple threads. If these variables are accessed by two or more threads at the same time it will produce unpredictable results. These operations cannot be termed as atomic.

This article describes how to ensure atomic operations in a multi-threaded environment.

Read more

Thread Synchronization: Avoiding Race Conditions

Race conditions occur when two or more threads try to gain control of the same object. In a threaded application multiple instances of threads run concurrently. These threads may share some variables such as counters or some other global objects. There is every chance that multiple threads simultaneously try to write values to the same object. This is known as a race condition.

Read more

Threading On Multi-Core CPUs

A multi-core processor combines two or more independent cores on a single chip. This multi-core architecture is adopted by most modern processors enabling execution of multiple threads simultaneously.

This article concentrates on how to optimize multithreading on multi-core CPUs.

Read more

File System Watcher And Large File Volumes

File system watcher listens to the file system change notifications and raises events when a directory, or file in a directory, changes. A very useful tool since it notifies exactly at the moment when a file or directory is created, changed or deleted, without having to do polling on that directory. It can watch sub-directories too.

If that wasn’t enough it also provides filters. For instance u just want notifications about text files then you can provide a filter “*.txt”, now event will be raised only for text files.

The Problem

However there is a downside. The file system watcher is not entirely reliable for working with large volumes of files. The reason for this is that there is a fixed buffer allocated to each file system watcher which is used to store the details such as file location for each file that raises an event. However when a large number of files raise an event then this buffer gets full.

Read more