kill thread in pthread
I use pthread_create(&thread1, &attrs, //... , //...); and need if some condition occured need to kill this thread how to kill this ? ...
I use pthread_create(&thread1, &attrs, //... , //...); and need if some condition occured need to kill this thread how to kill this ? ...
I downloaded pthread package from pthread. What should I do now to use it in DevC++? ...
When I use pthread_exit() in the initial thread, the initial thread switches in the terminated state. But I did not understand about the process. Can exist a running process with the initial thread in the termitated state? ...
In various multi threaded C and C++ projects I've seen the -pthread flag applied to both the compiling and linking stage while others don't use it at all and just pass -lpthread to the linking stage. Is there any danger not compiling and linking with the -pthread flag - i.e. what does -pthread actully do ? I'm primarly interrested in li...
For a user-lever thread library, I need to figure out jumping to a function by modifying PC value stored in jmp_buf. This is what I have written: jmp_buf env; void print (void) { printf("\nHello World!"); } static int ptr_mangle(int p) { unsigned int ret; asm(" movl %1, %%eax;\n" " xorl %%gs:0x18, %%eax;...
Hi, In linux, how can synchronize between 2 thread (using pthreads on linux)? I would like, under some conditions, a thread will block itself and then later on, it will be resume by another thread. In Java, there is wait(), notify() functions. I am looking for something the same on pthreads: I have read this, but it only has mutex, whi...
Having recently learned Grand Central Dispatch, I've found multithreaded code to be pretty intuitive(with GCD). I like the fact that no locks are required(and the fact that it uses lockless data structures internally), and that the API is very simple. Now, I'm beginning to learn pthreads, and I can't help but be a little overwhelmed wit...
If I try to compile a program with #include <pthread.h> in it, I get the error: pthread.h: No such file or directory Is it possible to get this to compile in a Windows environment? I am using Vista with the latest mingw I do not want to use the Microsoft Windows Services for UNIX Version 3.5 as I will have to move this to a Unix en...
In my destructor I want to destroy a thread cleanly. My goal is to wait for a thread to finish executing and THEN destroy the thread. The only thing I found about querying the state of a pthread is pthread_attr_setdetachstate but this only tells you if your thread is: PTHREAD_CREATE_DETACHED PTHREAD_CREATE_JOINABLE Both of those h...
Hey - I'm having an odd problem with a little toy program I've written, to try out threads. This is my code: #include <pthread.h> #include <iostream> using std::cout; using std::endl; void *threadFunc(void *arg) { cout << "I am a thread. Hear me roar." << endl; pthread_exit(NULL); } int main() { cout << "Hello there." <<...
I'm writing a multi-threaded C++ program. I plan on killing threads. However, I am also using a ref-counted GC. I'm wondering if stack allocated objects get destructed when a thread gets killed. ...
Having no experience with threading in the past, which threading technique in C++ will be the easiest for a beginner? boost::thread or pthreads? ...
My tools are Linux, gcc and pthreads. When my program calls new/delete from several threads, and when there is contention for the heap, 'arena's are created (see the following link for reference http://www.bozemanpass.com/info/linux/malloc/Linux_Heap_Contention.html). My program runs 24x7, and arenas are still occasionally being created ...
I am creating a data-parallel program using pthreads and C++. From http://stackoverflow.com/questions/1151582/pthread-function-from-a-class, I found out how to supply pthread_create with a function pointer to a static C++ function(and supply it a this argument). However, I also need to supply the thread with an index, so it knows what d...
Does anyone know a way to go from a pthread_t to what GDB displays with info threads? So I have: (gdb) info threads 37 Thread 22887 0xb7704422 in __kernel_vsyscall () 36 Thread 22926 0xb7704422 in __kernel_vsyscall () 35 Thread 22925 0xb7704422 in __kernel_vsyscall () 34 Thread 22924 0xb7704422 in __kernel_vsyscall () 33 ...
Hi, I have some questions regarding read write locks in POSIX Pthreads on a *nix system, say Linux for example. I wish to know what is the default bias for read write lock i.e does it prefer reads over writes or vice versa ? Does it provide some api to change this default behaviour. Does posix pthread provide some api so that we could...
This is the usage case: Log(char* s); // prints out a log message Now: Log("hello world\n"); // called from Thread1 Desired output: Thread1: hello world Now: Log("hello world\n"); // called from Thread2 Desired output: Thread2: hello world I can have a map that maps thread pids to strings. What I need however, is a functio...
I'm trying to implement a simulation of a microcontroller. This simulation is not meant to do a clock cycle precise representation of one specific microcontroller but check the general correctness of the code. I thought of having a "main thread" executing normal code and a second thread executing ISR code. Whenever an ISR needs to be ru...
I have a memory heap manager which partitions the heap into different segments based on the number of processors on the system. Memory can only be allocated on the partition that goes with the currently running thread's processor. This will help allow different processors to continue running even if two different ones want to allocate ...
In general, if you have a class that inherits from a Thread class, and you want instances of that class to automatically deallocate after they are finished running, is it okay to delete this? Specific Example: In my application I have a Timer class with one static method called schedule. Users call it like so: Timer::schedule((void*)o...