[erlang-questions] Does enif_schedule_nif schedule a NIF for the same scheduler thread?

Edmond Begumisa ebegumisa@REDACTED
Sun Nov 25 20:41:43 CET 2018


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 <rickard@REDACTED>  
wrote:

>
> sön 25 nov. 2018 kl. 08:33 skrev Edmond Begumisa  
> <ebegumisa@REDACTED>:
>> 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  
>> <ebegumisa@REDACTED> 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/



More information about the erlang-questions mailing list