aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/container.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-03-09 18:33:49 +0900
committerOphestra <cat@gensokyo.uk>2026-03-09 18:38:31 +0900
commit19a2737148609f0b40ea31cf5cd0cb809b60722f (patch)
treed1317481736578f02e81a7a9ce2d50c8776e3d40 /container/container.go
parentbaf2def9cc201ee4ae5bab2d31e35c7904d090f9 (diff)
container: sched policy string representation
This also uses priority obtained via sched_get_priority_min, and improves bounds checking. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/container.go')
-rw-r--r--container/container.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/container/container.go b/container/container.go
index 8b5ec01d..e7fd8cee 100644
--- a/container/container.go
+++ b/container/container.go
@@ -40,7 +40,7 @@ type (
AllowOrphan bool
// Scheduling policy to set via sched_setscheduler(2). The zero value
// skips this call. Supported policies are [SCHED_BATCH], [SCHED_IDLE].
- SchedPolicy int
+ SchedPolicy SchedPolicy
// Cgroup fd, nil to disable.
Cgroup *int
// ExtraFiles passed through to initial process in the container, with
@@ -373,12 +373,23 @@ func (p *Container) Start() error {
// sched_setscheduler: thread-directed but acts on all processes
// created from the calling thread
- if p.SchedPolicy > 0 {
+ if p.SchedPolicy > 0 && p.SchedPolicy <= _SCHED_LAST {
+ var param schedParam
+ if priority, err := p.SchedPolicy.GetPriorityMin(); err != nil {
+ return &StartError{
+ Fatal: true,
+ Step: "get minimum priority",
+ Err: err,
+ }
+ } else {
+ param.priority = priority
+ }
+
p.msg.Verbosef("setting scheduling policy %d", p.SchedPolicy)
if err := schedSetscheduler(
0, // calling thread
p.SchedPolicy,
- &schedParam{0},
+ &param,
); err != nil {
return &StartError{
Fatal: true,