Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to pause proc timer to erlang:suspend_process/2 #8670

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Nov 28, 2024

  1. [pause_proc_timer][1/n] Introduce ErtsPausedProcTimer type and operat…

    …ions
    
    We want a way to "pause" a proc timer when suspending a process, and
    "resume" it later. We will do this as follows.
    
      * Pausing a proc timer means:
        1. Cancelling the current timer in `common.timer`, if any.
        2. Storing in `common.timer` instead how much time was left in the
           timer. To compute the time left, we need to inspect the current
           timer.
        3. Flagging in the `Process` struct that the timer is paused. This is
           so that we know later that we need to resume the timer when resuming
           the process.
      * Resuming a proc timer then amounts to:
        1. Creating a new proc timer based on the time left that was stored
           in `common.timer`.
        2. Clear all the flags in the `Process` struct
      * When cancelling a proc timer, we now need to check if it is paused
        (in which case, it can just be ignored)
    
    So here we introduce a `ErtsPausedProcTimer` type, that will contain the
    time remaining on a paused timer, and a header that is shared with all
    other timer types (so that we can safely insert it in `common.timer`).
    
    We also introduce the functions to pause a proc timer and resume it.
    At this point nothing calls these functions, this happens in the next
    commits.
    jcpetruzza committed Nov 28, 2024
    Configuration menu
    Copy the full SHA
    825ddd3 View commit details
    Browse the repository at this point in the history

Commits on Nov 29, 2024

  1. [pause_proc_timer][2/n] Add pause_proc_timer option to suspend_process/2

    We add a new `pause_proc_timer` option to the `erlang:suspend_process/2`
    BIF. When given, the process is not only suspended, but its proc timer,
    if set, will be paused. This means that if the paused process is waiting
    on a `receive`, it will not timeout even if suspended for long.
    
    Each time pause_proc_timer is given, a counter is bumped in the
    suspend-process monitor. In order to decrease it, the (new) BIF
    `erlang:resume_process/2` needs to be called with the option
    `resume_proc_timer`. When the count reaches zero, the timer is
    resumed (even though the process may still be suspended).
    
    We add testcases for this functionality
    jcpetruzza committed Nov 29, 2024
    Configuration menu
    Copy the full SHA
    188faf1 View commit details
    Browse the repository at this point in the history