multithreading

Do the changes to cpumask using sched_setaffinity() take place immediately

I am writing a linux kernel module that needs to pin two threads on two different cpus. I am planning to use sched_setaffinity() after exporting it in the kernel. Is there any other exported function for the same ? Also, if I set only 1 CPU in the cpumask, will the thread be moved to that cpu with immediate effect ? If not, how do I en...

atomic writes to ehcache

Context I am storing a java.util.List inside ehcache. Key(String) --> List<UserDetail> The ordered List contains a Top 10 ranking of my most active users. Problem Concurrent 3rd party clients might be requesting for this list. I have a requirement to be as current as possible with regards to the ranking. Thus if the ranking is chan...

Do something else if ReadWriteSlimlock is held

Hi everyone, I have implemented ReaderWriterLockSlim, Now i don't want it to wait at the lock. I want to do something else if the lock is held. I considered using is isWriterLockHeld but it does not makes much sense to me, Since if two threads come in at the same time and enter the if statement at the same time one will still be waiti...

Task vs. process, is there really any difference?

Hi there, I'm studying for my final exams in my CS major on the subject distributed systems and operating systems. I'm in the need for a good definition for the terms task, process and threads. So far I'm confident that a process is the representation of running (or suspended, but initiated) program with its own memory, program counter...

Is there any cross-platform threading library in C or C++?

Hello, I'm looking for some easy to use cross-platform threading library written in C or C++. What's your opinion on boost::thread or Pthreads? Does Pthreads run only on POSIX compliant systems? What about the threading support in the Qt library? Thanks for any hints. ...

threading using simple c

hi all, i would like to implement a thread framework using simple c and timers....can anyone help me out...by providing some sample libraries or material... thanks in advance ...

Sending message from working non-gui thread to the main window

I'm using WinApi. Is SendMessage/PostMessage a good, thread safe method of communicating with the main window? Suppose, the working thread is creating a bitmap, that must be displayed on the screen. The working thread allocates a bitmap, sends a message with a pointer to this bitmap and waits until GUI thread processes it (for example u...

Is there a multithreaded map() function?

I have a function that is side effect free and I would like to run for every element in an array and return an array with all of the results. I'm wondering if python has something built into to generate all of the values. Thank you. ...

Cross-thread Winforms control editing

Hey, how can I edit the text in a windows form element if the code that is editing the text 'belongs' to a seperate thread from the one that contains the windows form? I get the exception: Cross-thread operation not valid: Control 'textBox1' accessed from a thread other than the thread it was created on. Thank you. ...

What happens to an instance of ServerSocket blocked inside accept(), when I drop all references to it?

In a multithreaded Java application, I just tracked down a strange-looking bug, realizing that what seemed to be happening was this: one of my objects was storing a reference to an instance of ServerSocket on startup, one thread would, in its main loop in run(), call accept() on the socket while the socket was still waiting for a conne...

CPU Affinity Masks (Putting Threads on different CPUs)

I have 4 threads, and I am trying to set thread 1 to run on CPU 1, thread 2 on CPU 2, etc. However, when I run my code below, the affinity masks are returning the correct values, but when I do a sched_getcpu() on the threads, they all return that they are running on CPU 4. Anybody know what my problem here is? Thanks in advance! #defi...

Broken Multithreading With Core Data

This is a better-focused version of an earlier question that touches upon an entirely different subject from before. I am working on a Cocoa Core Data application with multiple threads. There is a Song and Artist; every Song has an Artist relation. There is a delegate code file not cited here; it more or less looks like the template XCo...

Registering an event from different thread

Hi, I have a question regarding events in c#. Lets say I have an object obj1 of a class that exposes an event, and this object is running on thread t1. Now on different thread t2, there is another object called obj2 that is registered for the event of obj1. Is it promised that obj2 will get the event when it will be raised? thanks. ...

Multiple things at once (Threads?)

All, What is a really simple way of having a program do more than one thing at once, even if the computer does not necessarily have multiple 'cores'. Can I do this by creating more than one Thread? My goal is to be able to have two computers networked (through Sockets) to respond to each-other's requests, while my program will at the s...

Java's Swing Threading

My understanding is that if I start up another thread to perform some actions, I would need to SwingUtilities.invokeAndWait or SwingUtilities.invokeLater to update the GUI while I'm in said thread. Please correct me if I'm wrong. What I'm trying to accomplish is relatively straightforward: when the user clicks submit, I want to (before ...

.NET Working with Locking and Threads

Work on this small test application to learn threading/locking. I have the following code, I would think that the line should only write to console once. However it doesn't seem to be working as expected. Any thoughts on why? What I'm trying to do is add this Lot object to a List, then if any other threads try and hit that list, it w...

C or C++ Win32 How can I obtain the number of threads running in my program?

On Win32, how can a C++ program determine how many threads are active in my program's process? Is there an API call? ...

Synchronization requirements for FileStream.(Begin/End)(Read/Write)

Is the following pattern of multi-threaded calls acceptable to a .Net FileStream? Several threads calling a method like this: ulong offset = whatever; // different for each thread byte[] buffer = new byte[8192]; object state = someState; // unique for each call, hence also for each thread lock(theFile) { theFile.Seek(whatever, See...

640 enterprise library caching threads - how?

We have an application that is undergoing performance testing. Today, I decided to take a dump of w3wp & load it in windbg to see what is going on underneath the covers. Imagine my surprise when I ran !threads and saw that there are 640 background threads, almost all of which seem to say the following: OS Thread Id: 0x1c38 (651) Child-...

How to implement blocking request-reply using Java concurrency primitives?

My system consists of a "proxy" class that receives "request" packets, marshals them and sends them over the network to a server, which unmarshals them, processes, and returns some "response packet". My "submit" method on the proxy side should block until a reply is received to the request (packets have ids for identification and refer...