Erlang/OTP Forums

Author Message

<  Advanced Erlang/OTP  ~  limiting the max. reductions of a process

zghst
Posted: Sat Aug 15, 2009 12:46 pm Reply with quote
Joined: 15 Aug 2009 Posts: 6
hello.
I'd like specify the max number of reductions of a process at spawn. (for the reduction number as found in process_info). When it goes over, the process should be killed.

I think I read Erlang switches between processes every x reductions. Could I hack into the system somehow to do this extra check here (and kill the process if needed)? I'm not very familiar with the erlang source code. Does anyone know if this would be a hard thing to do?

Or I could make a separate process with a higher priority to check all the reduction numbers every 100 ms or so.

Any ideas on how to best do this? Thanks for the help
View user's profile Send private message
zghst
Posted: Sat Aug 15, 2009 1:23 pm Reply with quote
Joined: 15 Aug 2009 Posts: 6
I'd also like to get the number of reductions a process did along with the 'EXIT' message somehow. So I can know how many reductions each process did at the time of exit. (Calling process_info for the reductions number on a dead process doesnt work)
View user's profile Send private message
uwiger
Posted: Sat Aug 15, 2009 5:20 pm Reply with quote
User Joined: 03 Jul 2006 Posts: 604 Location: Sweden
zghst wrote:
hello.
I'd like specify the max number of reductions of a process at spawn. (for the reduction number as found in process_info). When it goes over, the process should be killed.


This is not supported, unfortunately.

I do something like that in ErlHive, but it's done through source transforms in a controlled environment.

You could create your own behaviour on top of e.g. gen_server or gen_fsm, and insert this sort of check before you hand over to the callbacks.

BR,
Ulf W
View user's profile Send private message Visit poster's website
zghst
Posted: Sun Aug 16, 2009 6:36 am Reply with quote
Joined: 15 Aug 2009 Posts: 6
hi, thanks for the reply
Adding a check before the call handle is a cool idea. But all this seems like a lot of trouble/overhead, when it just seems like adding a simple check in the erlang runtime system (since they already keep the reduction number).

Would this be possible to add in erts/emulator/beam/erl_process.c somewhere? (Just making the scheduler skip the process would work for me, i think)
View user's profile Send private message
wuji
Posted: Thu Aug 30, 2012 6:39 am Reply with quote
User Joined: 10 Aug 2012 Posts: 654
of those life highlights I will never forget and was was cheap jordan shoes was fortunate enough to experience again at the opening ceremonies
Beijing, with Jimi pushing me into the birds nest."Tragedy Strikes Strikes designer replica *beep* Strikes a Second Time for Dave DennistonIt was one of
happiest moments in Denniston's life -- one that he would would cheap Ralph Lauren would remember in 2009, when he faced a second deep,
tragedy."I got a phone call from a friend and he he cheap Ralph Lauren Polo he said, 'Did you hear about Jimi?'"Denniston had not --
then he got the news that Flowers had died in in cheap jordan shoes in a fall while climbing a mountain in Aspen."For me,
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum