Add the context.PrepareSleep platform callback.

It is called only when a task switches to the interruptible sleep, because it
is the only state where the task can sleep for a long time.

PiperOrigin-RevId: 485963460
This commit is contained in:
Andrei Vagin
2022-11-03 13:50:24 -07:00
committed by gVisor bot
parent b322d1cc5b
commit 1497cdffce
4 changed files with 11 additions and 0 deletions
+1
View File
@@ -189,6 +189,7 @@ func (t *Task) block(C <-chan struct{}, timerChan <-chan struct{}) error {
// prepareSleep prepares to sleep.
func (t *Task) prepareSleep() {
t.assertTaskGoroutine()
t.p.PrepareSleep()
t.Deactivate()
t.accountTaskGoroutineEnter(TaskGoroutineBlockedInterruptible)
}
+3
View File
@@ -126,3 +126,6 @@ func (c *context) FullStateChanged() {}
// PullFullState implements platform.Context.PullFullState.
func (c *context) PullFullState(as platform.AddressSpace, ac *arch.Context64) {}
// PrepareSleep implements platform.Context.platform.Context.
func (*context) PrepareSleep() {}
+4
View File
@@ -244,6 +244,10 @@ type Context interface {
// Release() releases any resources associated with this context.
Release()
// PrepareSleep() is called when the tread switches to the
// interruptible sleep state.
PrepareSleep()
}
var (
+3
View File
@@ -199,6 +199,9 @@ func (c *context) FullStateChanged() {}
// PullFullState implements platform.Context.PullFullState.
func (c *context) PullFullState(as platform.AddressSpace, ac *arch.Context64) {}
// PrepareSleep implements platform.Context.platform.PrepareSleep.
func (*context) PrepareSleep() {}
// PTrace represents a collection of ptrace subprocesses.
type PTrace struct {
platform.MMapMinAddr