MCPcopy Index your code
hub / github.com/google/gvisor / Getpriority

Function Getpriority

pkg/sentry/syscalls/linux/sys_thread.go:716–747  ·  view source on GitHub ↗

Getpriority pretends to implement the linux syscall getpriority(2). This is a stub; real priorities require a full scheduler.

(t *kernel.Task, sysno uintptr, args arch.SyscallArguments)

Source from the content-addressed store, hash-verified

714//
715// This is a stub; real priorities require a full scheduler.
716func Getpriority(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
717 which := args[0].Int()
718 who := kernel.ThreadID(args[1].Int())
719
720 switch which {
721 case linux.PRIO_PROCESS:
722 // Look for who, return ESRCH if not found.
723 var task *kernel.Task
724 if who == 0 {
725 task = t
726 } else {
727 task = t.PIDNamespace().TaskWithID(who)
728 }
729
730 if task == nil {
731 return 0, nil, linuxerr.ESRCH
732 }
733
734 // From kernel/sys.c:getpriority:
735 // "To avoid negative return values, 'getpriority()'
736 // will not return the normal nice-value, but a negated
737 // value that has been offset by 20"
738 return uintptr(20 - task.Niceness()), nil, nil
739 case linux.PRIO_USER:
740 fallthrough
741 case linux.PRIO_PGRP:
742 // PRIO_USER and PRIO_PGRP have no further implementation yet.
743 return 0, nil, nil
744 default:
745 return 0, nil, linuxerr.EINVAL
746 }
747}
748
749// Setpriority pretends to implement the linux syscall setpriority(2).
750//

Callers

nothing calls this directly

Calls 5

NicenessMethod · 0.95
ThreadIDTypeAlias · 0.92
TaskWithIDMethod · 0.80
IntMethod · 0.45
PIDNamespaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…