English 中文(简体)
Linux Virtual Timer Behavior on Clone Threads
原标题:

I have done the following:

  1. Create a virtual timer that triggers repeatedly.
  2. Install signal handler for SIGVTALRM
  3. Call clone syscall
  4. Set sched_affinity such that the cloned thread runs on a different CPU

Will the cloned thread also be listening for SIGVTALRM? So will both the threads call the signal handler when SIGVTALRM is triggered? Also, after creating the new thread, can I change its signalhandler for SIGVTALRM to another function without affecting the main threads signalhandler?

I m guessing it depends on the flags passed to clone(). Mainly, I m using CLONE_SIGHAND and SIGCHLD. Does it depend on other flags as well?

最佳回答

It depends entirely on whether you specify CLONE_THREAD to the clone syscall. If you do not, then the itimer is not inherited by the child (so it will not be signalled when the timer expires). It will still have a signal handler installed though.

If you do specify CLONE_THREAD, then the child is considered to belong to the same process as the parent. When the timer expires, one of the threads will be signalled (and run the signal handler) - but it s not specified which one.

What happens if when you try to change the signal handler in the child depends on the CLONE_SIGHAND flag. If it s not set, then the child can happily call sigaction to change the signal handler without affecting the parent; but if CLONE_SIGHAND is set, then when the child calls sigaction, the signal handler is changed for the entire process. Note also that if you specify CLONE_THREAD, you also have to specify CLONE_SIGHAND.

The child can, however, use sigprocmask to mask out the SIGVTALRM signal, without affecting the parent.

问题回答

暂无回答




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签