Does enif_schedule_nif schedule a NIF for the same scheduler thread?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Does enif_schedule_nif schedule a NIF for the same scheduler thread?

Edmond Begumisa
Hello all,

If I call enif_schedule_nif from a regular scheduler thread with the flags  
argument set to zero, when the emulator gets around to executing it, will  
my scheduled NIF be called from the very same regular scheduler thread as  
when I called enif_schedule_nif? Or could it be any regular scheduler  
thread?

Thanks in advance.

- Edmond -

--
Using Opera's mail client: http://www.opera.com/mail/
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Does enif_schedule_nif schedule a NIF for the same scheduler thread?

Edmond Begumisa
PS. I guess the same question applies to ERL_NIF_DIRTY_JOB_CPU_BOUND or  
ERL_NIF_DIRTY_JOB_IO_BOUND flags when enif_schedule_nif is called from a  
dirty CPU/IO scheduler. Will the future NIF be executed on the very same  
dirty CPU/IO scheduler thread?

- Edmond -

On Sun, 25 Nov 2018 17:26:34 +1000, Edmond Begumisa  
<[hidden email]> wrote:

> Hello all,
>
> If I call enif_schedule_nif from a regular scheduler thread with the  
> flags argument set to zero, when the emulator gets around to executing  
> it, will my scheduled NIF be called from the very same regular scheduler  
> thread as when I called enif_schedule_nif? Or could it be any regular  
> scheduler thread?
>
> Thanks in advance.
>
> - Edmond -
>


--
Using Opera's mail client: http://www.opera.com/mail/
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Does enif_schedule_nif schedule a NIF for the same scheduler thread?

Rickard Green-2

sön 25 nov. 2018 kl. 08:33 skrev Edmond Begumisa <[hidden email]>:
PS. I guess the same question applies to ERL_NIF_DIRTY_JOB_CPU_BOUND or 
ERL_NIF_DIRTY_JOB_IO_BOUND flags when enif_schedule_nif is called from a 
dirty CPU/IO scheduler. Will the future NIF be executed on the very same 
dirty CPU/IO scheduler thread?

- Edmond -

On Sun, 25 Nov 2018 17:26:34 +1000, Edmond Begumisa 
<[hidden email]> wrote:

> Hello all,
>
> If I call enif_schedule_nif from a regular scheduler thread with the 
> flags argument set to zero, when the emulator gets around to executing 
> it, will my scheduled NIF be called from the very same regular scheduler 
> thread as when I called enif_schedule_nif? Or could it be any regular 
> scheduler thread?
>
> Thanks in advance.
>
> - Edmond -
>

It may be scheduled on any scheduler of the requested type.

Regards,
Rickard Green, Erlang/OTP, Ericsson AB

--
Rickard Green, Erlang/OTP, Ericsson AB

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Does enif_schedule_nif schedule a NIF for the same scheduler thread?

Edmond Begumisa
I see, thanks Rickard.

It would be nice to have a flag which specifies that the future NIF should  
be scheduled on the same thread. Assuming this is technically possible,  
perhaps the OTP team could consider this.

There are cases where one would want to break work up that's not  
threadsafe to continue from a different thread. In my particular case, I  
have different need -- I'm trying to send potentially large messages to  
another thread and/or OS process via a Boost.Lockfree Single-Producer  
Single Consumer Queue [1], so each message should be sent from the same  
[dirty] scheduler thread (the producer).

- Edmond -

[1] https://www.boost.org/doc/libs/1_68_0/doc/html/lockfree.html

On Sun, 25 Nov 2018 22:57:40 +1000, Rickard Green <[hidden email]>  
wrote:

>
> sön 25 nov. 2018 kl. 08:33 skrev Edmond Begumisa  
> <[hidden email]>:
>> PS. I guess the same question applies to ERL_NIF_DIRTY_JOB_CPU_BOUND or  
>> ERL_NIF_DIRTY_JOB_IO_BOUND flags when enif_schedule_nif is called from  
>> a  
>> dirty CPU/IO scheduler. Will the future NIF be executed on the very  
>> same  
>> dirty CPU/IO scheduler thread?
>>
>>
>>
>> - Edmond -
>>
>>
>>
>> On Sun, 25 Nov 2018 17:26:34 +1000, Edmond Begumisa  
>> <[hidden email]> wrote:
>>
>>
>>
>>> Hello all,
>>
>>>
>>
>>> If I call enif_schedule_nif from a regular scheduler thread with the
>>
>>> flags argument set to zero, when the emulator gets around to executing
>>
>>> it, will my scheduled NIF be called from the very same regular  
>>> scheduler
>>
>>> thread as when I called enif_schedule_nif? Or could it be any regular
>>
>>> scheduler thread?
>>
>>>
>>
>>> Thanks in advance.
>>
>>>
>>
>>> - Edmond -
>>
>>>
>
> It may be scheduled on any scheduler of the requested type.
>
> Regards,
> Rickard Green, Erlang/OTP, Ericsson AB
>
> --Rickard Green, Erlang/OTP, Ericsson AB
>



--
Using Opera's mail client: http://www.opera.com/mail/
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions