- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
On Linux signal-handlers are thread-specific, and I would like to ensure that a signal handler is registered for each thread spawned by TBB for work.
Is there a sane way to do this?
On Linux signal-handlers are thread-specific, and I would like to ensure that a signal handler is registered for each thread spawned by TBB for work.
Is there a sane way to do this?
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have a look at task_scheduler_observer, but it does sound mighty suspicious what you're considering there...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If scheduler observer is called too frequently, initializing a signal handler is going to be rather wasteful considering it only needs to be called once at initialization. Unless the observer has some hook that is only called once?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmm, but wouldn't you then also need a hook for the hook for the hook... :-)
It won't work unless you try it.
It won't work unless you try it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know that using the observer will "work", and that is not what I was asking. The observer is going to be called as worker threads obtain work, so far as I can see, and that is extremely wasteful to put initialization code in that area that is frequently checked. Especially if the initialization code requires synchronization to ensure that this was a thread seen before to be initialized.
I appreciate your suggestion to look at the observer, but this is not what I want.
I appreciate your suggestion to look at the observer, but this is not what I want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It won't work unless you try it...
(2012-08-15 Added after #7) Sorry for not being more explicit earlier, but the calls happen very infrequently indeed (probably only twice in a worker thread's lifetime, perhaps more if an application thread explicitly uses different task_scheduler_init instances?).
(2012-08-15 Added after #7) Sorry for not being more explicit earlier, but the calls happen very infrequently indeed (probably only twice in a worker thread's lifetime, perhaps more if an application thread explicitly uses different task_scheduler_init instances?).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting AJ
The observer is going to be called as worker threads obtain work, so far as I can see, and that is extremely wasteful to put initialization code in that area that is frequently checked.
Why do you think an observer is called each time a thread obtains a work? Please read the documentation, oberver is guaranteed to be called once per thread after activation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The documentation states: "A task_scheduler_observer permits clients to observe when a thread starts or
stops participating in task scheduling." This is all the information provided.
Given this sentence, I inferred that the observer will be called during scheduling of tasks, in particular on the transition from an empty work-pool to a non-empty workpool. Perhaps this can be better worded?
Given this sentence, I inferred that the observer will be called during scheduling of tasks, in particular on the transition from an empty work-pool to a non-empty workpool. Perhaps this can be better worded?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I agree.. probably some hints lurk in callbacks description but the description is not clear enough.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page