This is a bit of a meta question since I think I have a solution that works for me, but it has its own downsides and upsides. I need to do a fairly common thing, catch SIGSEGV on a thread (no dedicated crash handling thread), dump some debug information and exit. The catch here is the fact that upon crash,
Tag: multithreading
Segmentation Fault on pthread_create
I am having an issue with the following C code. The code itself is supposed to create 5 threads that simulate the Dining Philosophers problem in which threads are accessing shared data. The code follows: I am on a Linux virtual machine, using gedit. The program compiles fine, but upon attempting to run it, I am getting a “Segmentation Fault”
what is “synchronising point” in multi threading?
I need to decide on how many counting semaphores needs to be used for one of the multi threaded application. I came to know, if we know synchronising points then we can decide the number of semaphores to be used. What are synchronising points? Answer A synchronization point is a place in the flow of execution where a thread must
Client/Server pthreads program not executing under Valgrind. Runs fine normally
I have a C server program that creates & opens the write end of a named pipe (in /var/run), and interrupts on a SIGIO signal for a tty uart, pushing data into the pipe from that interface. This program also spawns a secondary pthread, which opens the read end of a separate pipe (again, in /var/run), reads from it (blocking),
Error in malloc while trying to create a thread
Hi everyone i post only the core of the code which create probleam and which work with threads. As we can see foo function create new thread and reallocate memory to store the pthread_t. Then it try to create a new thread with pthread_create as NULL as attr and arg and as function pointer a pointer to foo2; Now the
pthread_kill() not sending signal to main thread (main program)
signal can be received in any threads or main program itself. i have created one auxiliary thread from main program. so there is two thread in my program 1. main thread (process itself) 2. Auxiliary Thread. I just want that whenever signal arrived in my auxiliary thread, that should send signal to my main thread (program). i am using pthread_kill(main_threadid,
Alternate to setpriority(PRIO_PROCESS, thread_id, priority)
Given – Thread id of a thread. Requirement – Set Linux priority of the thread id. Constraint – Cant use setpriority() I have tried to use below pthread_setschedprio(pthread_t thread, int prio); pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param); Both the above APIs use pthread_t as an argument. I am not able to construct (typecast) pthread_t from thread id. I
Wait for popen script to terminate in C
Is that possible with C to wait until the popen subprocess is finished? I have a script launched by a C daemon which will connect to a wifi network when an external signal is triggered. Here is my code for now : However, I’m not waiting for the subprocess to finish so when I’m closing the pipe, the ressource is
Which OS / platforms implement wait morphing optimization?
Which major OS / platforms implement wait morphing? This question came up when I noticed that there’s no clearcut best practice about whether one should signal a condition variable with mutex locked or not. A typical recommendation is to signal while holding the lock unless profiling shows a substantial performance improvement overhead from unlocking (by removing an extra context switch).
How can I measure CPU time of a specific set of threads?
I run C++ program in Linux. There are several threads pool (for computation, for io, for … such things). The system call clock() gives me a way to measure the CPU time spent by all the CPU cores for the process. However, I want to measure the CPU time spent only by the threads in the computation threads pool. How