multithreading

multithreading or multiprocessing

I am designing a dedicated syslog-processing daemon for Linux that needs to be robust and scalable and I'm debating multithread vs. multiprocess. The obvious objection with multithreading is complexity and nasty bugs. Multi-processes may impact performance because of IPC communications and context switching. "The Art of Unix Programmi...

Missing OpenMP feature: Thread Priority

Anyone think about it. OpenMP features to adjust cpu muscles to handle dumbbel. In my research for openmp we cannot set thread priority to execute block code with powerfull muscle. Only one way(_beginthreadex or CreateThread function with 5. parameters) to create threads with highest priority. Here some code for this issue: This is m...

Getting ApplicationState in asp.net without HttpContext

I got a webapp that stores a config object in ApplicationState. This object contains the connection string to the database among other things. Sometimes i start a async thread to do a few longer running tasks, like sending emails and updating the database. However since this thread don't have a HttpContext i can't get at the config obj...

Best approach to fire Thread/Process under IIS/WCF, in a shared hosting.

Hi, Scenario: A WCF service receives an XDocument from clients, processes it and inserts a row in an MS SQL Table. Multiple clients could be calling the WCF service simultaneously. The call usually doesn't take long (a few secs). Now I need something to poll the SQL Table and run another set of processes in an asynchronous way. The ...

TransactionScope and multi-threading

Hi, I was wondering how you would use the TransactionScope class in the correct way when you are dealing with multithreading? We create a new scope in our main thread and then we spawn of a couple of worker threads and we want these to participate in the main scope, so that for example the rollback is called on each worker if the scope...

System Wide persistent storage?

My program starts a process and I need to make sure it is killed before I can run the program again. To do this, I'd like to store the start time of the Process in something like a mutex that I could later retrieve and check to see if any process has a matching name and start time. How could I do this? I don't really want to stick anyth...

application domains and threads

A quote from MSDN: http://msdn.microsoft.com/en-us/library/6kac2kdh.aspx One or more managed threads (represented by System.Threading.Thread) can run in one or any number of application domains within the same managed process. Although each application domain is started with a single thread, code in that application d...

Difference between Monitor.Pulse and Monitor.PulseAll

Monitor.PulseAll notifies all waiting threads in the queue. Monitor.Pulse notifies a thread in the waiting queue. (The next waiting thread) Only the next Thread (1 Thread) can acquire the lock. So what is the difference? When should i use Pulse and when PulseAll? ...

Threads in Flash and Flex

Are threads possible in Flash, Actionscript and Flex just like in C# and Java? ...

How do we perform multi threading application in C#?

Duplicate of c# threading Beginners threading in C# Multithreading reference? Can any body provide some good examples, codes for multi threading in c#.. I tried on google but I need examples with good explanation about what is happening at what point? ...

Silverlight: How to obtain ProcessorCount?

I have a computationally intensive task that users can perform using a Silverlight app. It is a very easy task to parallelize. My problem is that the System.Environment.ProcessorCount is Security Critical, so I can't easily check that. I don't want to just QueueUserWorkItem because I don't want to have more than the number of process...

setjmp/signal crash exception handling

I am trying to install a "crash handler" for a C OSX Carbon multithreaded application. On Windows, I can easily use the simple and efficient try{} __except{} SEH of Windows which works great. (Note these are **unrelated to C++ exceptions, these are lower level C constructs!) This is very related to a question I asked on SO previously: ...

C# threads for file manipulation

I have to be able to save a file, unfortunatly it can potentially be very large so saving it can potentially take minutes. As I need to do this from a GUI thread I don't want to block the GUI from executing. I was thinking about attempting the save operation on a seperate thread to allow the primary GUI thread to continue executing. Is ...

Data corruption when threading Vector Statistical Library-Math Kernel Library

I've just parallelized a fortran routine that simulates individuals behavior and I've had some problems when generating random numbers with Vector Statistical Library (a library from the Math Kernel Library). The structure of the program is the following: program example ... !$omp parallel do num_threads(proc) default(none) private(...)...

issue/response serial port processing in C#

Okay here's the problem (this is related to a previous post of mine) I need to be able to have an issue/response system for serial comms that works something like this: issue: hello response: world? issues: no, hello nurse reponse: well you're no fun. this would mean I say "hello" the remote unit is expected to send back "world?" with...

Semaphore queues

I'm extending the functionality of a semaphore. I ran into a roadblock when I realized I don't know the implementation of an actual semaphore and to make sure my code ran correctly, I needed to know this. I know a semaphore works by blocking threads that are waiting on it when they call sem_wait() and another thread currently has it lo...

I've heard i++ isn't thread safe, is ++i thread-safe?

I've heard that i++ isn't a thread-safe statement since in assembly it reduces down to storing the original value as a temp somewhere, incrementing it, and then replacing it, which could be interrupted by a context switch. However, I'm wondering about ++i. As far as I can tell, this would reduce to a single assembly instruction, such as...

A question about semaphore.

#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <semaphore.h> void *thread_function(void *arg); sem_t bin_sem; #define WORK_SIZE 1024 char work_area[WORK_SIZE]; int main() { int res; pthread_t a_thread; void *thread_result; res = sem_init(&bin_sem, 0, 0); if...

Where to stop/destroy threads in Android Service class?

I have created a threaded service the following way: public class TCPClientService extends Service{ ... @Override public void onCreate() { ... Measurements = new LinkedList<String>(); enableDataSending(); } @Override public IBinder onBind(Intent intent) { //TODO: Replace with service binding implementation re...

Is PHP thread-safe

Is PHP (as of 5.2) thread-safe on Linux/UNIX? Would it be possible to use it with Apache Worker-MPM or Event-MPM? The facts I gathered so far are inconclusive: default binaries included in most distributions have ZTS disabled, so I aware, that I'd have to recompile them. in theory Zend Engine (core PHP) with ZTS enabled is thread...