in Education by
How can I pass arguments (e.g. a pointer to a struct) to a signal handler? I'm writing a multithread application, so I cannot use global variables I associate a timer to each thread. When timer expires I have to update a struct (each thread has a different struct). How can I do? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The way the signal handler is called by the system is fixed -- there's no way to change it and add an additional user pointer. So if you want to get additional data into the signal handler, the only way to do it is with a global variable (which could be thread-local). However, if you are trying to use timer_create with threads, you are much better off using SIGEV_THREAD rather than SIGEV_SIGNAL. The latter sends the signal to the process rather than the thread, so it might be caught by any thread in the process.

Related questions

0 votes
    How to pass a parameter to an event handler or callback in REACT?...
asked Jun 2, 2021 in Education by JackTerrance
0 votes
    I have a code and I need to pass the arguments like name from terminal. Here is my code and how ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 27, 2022 in Education by JackTerrance
0 votes
    I have a code and I need to pass the arguments like name from terminal. Here is my code and how ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    What are command line arguments in C Programming?...
asked Jan 18, 2021 in Technology by JackTerrance
0 votes
    What is the first string in the argument vector w.r.t command line arguments in C?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    Which operator is used to receive the variable number of arguments for a function in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    What are command line arguments in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    first question asked, so I'll get straight to it. I've got some C code that will be interfacing ... Arguments: java_command: Launcher Type: generic Environment Variables: PATH=...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    In C, how can i pass more than one argument to a thread? Normally, I do it in a way like, ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    In the circuit given below, C= C1 = C2. The gain of the multiple-feedback band-pass filter is ___________ (a) ... for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    What is the difference between pass by value by reference in c and pass by reference in c?...
asked Jan 21, 2021 in Technology by JackTerrance
0 votes
    What is a handler in Ansible?...
asked Jan 29, 2023 in Technology by JackTerrance
0 votes
    Which module can be used to force a handler to run in between two tasks? (1)meta (2)asset (3)flush (4)None of the options...
asked Jan 26, 2023 in Technology by JackTerrance
0 votes
    I am trying to use the standard code to email a workbook to multiple recipients but build in some error ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 27, 2022 in Education by JackTerrance
0 votes
    I am having problems with the event handler in my office addin . Below is an example code i got ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
...