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)
| 714 | // |
| 715 | // This is a stub; real priorities require a full scheduler. |
| 716 | func 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 | // |
nothing calls this directly
no test coverage detected
searching dependent graphs…