Worker Thread Signal Handlers

Worker Thread Signal Handlers

imagem de AJ

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?

9 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de Raf Schietekat

Have a look at task_scheduler_observer, but it does sound mighty suspicious what you're considering there...

imagem de AJ

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?

imagem de Raf Schietekat

Hmm, but wouldn't you then also need a hook for the hook for the hook... :-)

It won't work unless you try it.

imagem de AJ

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.

imagem de Raf Schietekat

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?).

imagem de Anton Malakhov (Intel)

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.

imagem de AJ

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?

imagem de Anton Malakhov (Intel)

I agree.. probably some hints lurk in callbacks description but the description is not clear enough.

Faça login para deixar um comentário.