GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add `SCHED_DEADLINE` and `SCHED_NORMAL` constants to `os` module · Issue #127688 · python/cpython

Add SCHED_DEADLINE and SCHED_NORMAL constants to os module #127688

New issue
Copy link
New issue
Copy link
Closed
Closed
Add SCHED_DEADLINE and SCHED_NORMAL constants to os module#127688
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement

Description

@rruuaanng
rruuaanng
opened on Dec 6, 2024
Issue body actions

Feature or enhancement

Proposal:

This issue suggests adding new os constants.

os.SCHED_DEADLINE

# deadline scheduling
# Set the current schedule to real-time schedule, To be precise, it
# is not real-time scheduling, but it is relatively real-time.
prio = os.sched_param(sched_priority=10)
os.sched_setscheduler(0, os.SCHED_DEADLINE, prio)

SCHED_NORMAL is the same as SCHED_OTHER.
But to run in the old linux, we can't remove SCHED_OTHER, even if it no longer exists in the current main branch.
But we still need to add SCHED_NORMAL, because SCHED_OTHER only exists in the old distribution.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-127688: Add SCHED_DEADLINE and SCHED_NORMAL constants to os module #127689

Activity

  1. rruuaanng
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Dec 6, 2024
  2. rruuaanng
    changed the title [-]Add SCHED_DEADLINE and SCHED_NORMAL constants to `os` module[/-] [+]Add `SCHED_DEADLINE` and `SCHED_NORMAL` constants to `os` module[/+] on Dec 6, 2024
  3. picnixz
    added
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Dec 6, 2024
  4. encukou commented on Dec 13, 2024

    @encukou
    encukou
    on Dec 13, 2024
    Member
    More actions

    I don't have SCHED_NORMAL on my Fedora 41. I'd like to test with a system that has it; are you aware of one?

  5. rruuaanng commented on Dec 14, 2024

    @rruuaanng
    rruuaanng
    on Dec 14, 2024
    ContributorAuthor
    More actions

    Can you try running the following code? SCHED_NORMAL has been present in Linux 2.6.12 and still exists in later versions.

    #include <linux/sched.h>
    #include <stdio.h>                                                                                                                                                                                                                                                                                                                                                      
    int main()
    {
            printf("%d ", SCHED_NORMAL);
            /* It should output 0 */
            return 0;
    }
    

    In pyrepl

    >>> import os
    >>> os.SCHED_NORMAL
    0
    >>> os.SCHED_OTHER
    0
    

    ref:
    https://github.com/torvalds/linux/blob/9ee1c939d1cb936b1f98e8d81aeffab57bae46ab/include/linux/sched.h#L132
    my os: Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-86-generic x86_64)

    Edit

    etc. That was actually my mistake, we should have imported linux/sched.h, not sched.h. Our existing posixmodule.c uses sched.h.

  6. encukou commented on Dec 16, 2024

    @encukou
    encukou
    on Dec 16, 2024
    Member
    More actions

    Looking around, it seems like the kernel headers in linux/*.h are meant for the kernel, rather than user-space programs -- e.g. from this LWN article:

    The use of kernel headers in user space has long been discouraged.

    I didn't find any official source saying it's OK to include linux/sched.h outside the kernel. Am I overthinking this?

  7. rruuaanng commented on Dec 17, 2024

    @rruuaanng
    rruuaanng
    on Dec 17, 2024
    ContributorAuthor
    More actions

    I didn't find any official source saying it's OK to include linux/sched.h outside the kernel. Am I overthinking this?

    What I mean is, yes.

    Looking around, it seems like the kernel headers in linux/*.h are meant for the kernel

    Typically, GCC searches using the following paths, assuming you haven’t changed them. Additionally, linux/*.h files are divided into kernel-space and user-space headers. Only when compiling a kernel module will it link to the kernel header files.

    #include "..." search starts here:
    #include <...> search starts here:
     /usr/lib/gcc/x86_64-linux-gnu/11/include
     /usr/local/include
     /usr/include/x86_64-linux-gnu
     /usr/include
    End of search list.
    # 0 "/dev/null"
    # 0 "<built-in>"
    # 0 "<command-line>"
    # 1 "/usr/include/stdc-predef.h" 1 3 4
    # 0 "<command-line>" 2
    # 1 "/dev/null"
    COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/
    LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../:/lib/:/usr/lib/
    COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic' '-march=x86-64'
    

    https://github.com/torvalds/linux/blob/f44d154d6e3d633d4c49a5d6aed8a0e4684ae25e/include/uapi/linux/sched.h#L114
    You will find that the content of your /usr/include/linux/sched.h is almost the same as it.

    Edit

    This may not be convincing as they are not exactly similar, but we import multiple linux/*.h in posixmodule.c and I don't think it matters.

    #ifdef HAVE_LINUX_RANDOM_H
    #  include <linux/random.h>
    #endif
    #ifdef HAVE_LINUX_MEMFD_H
    #  include <linux/memfd.h>
    #endif
    #ifdef HAVE_LINUX_WAIT_H
    #  include <linux/wait.h>         // P_PIDFD
    #endif
    
    Reacted by Petr Viktorin
  8. encukou
    added a commit that references this issue on Dec 19, 2024

    gh-127688: Add `SCHED_DEADLINE` and `SCHED_NORMAL` constants to `os` …

    ea578fc
  9. encukou commented on Dec 19, 2024

    @encukou
    encukou
    on Dec 19, 2024
    Member
    More actions

    OK.
    Merged, thank you for the contribution!

    Reacted by RUANG (James Roy)
  10. encukou
    closed this as completedon Dec 19, 2024
  11. srinivasreddy
    added a commit that references this issue on Dec 23, 2024

    pythongh-127688: Add `SCHED_DEADLINE` and `SCHED_NORMAL` constants to…

    dd5fcc0
  12. srinivasreddy
    added a commit that references this issue on Jan 8, 2025

    pythongh-127688: Add `SCHED_DEADLINE` and `SCHED_NORMAL` constants to…

    0404a34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.