{"id":16765111,"url":"https://github.com/dataplayer12/sched_deadline","last_synced_at":"2025-03-16T11:25:49.040Z","repository":{"id":111555326,"uuid":"504592336","full_name":"dataplayer12/sched_deadline","owner":"dataplayer12","description":"Minimal example of using SCHED_DEADLINE for realtime scheduling of C programs in Linux","archived":false,"fork":false,"pushed_at":"2022-08-24T15:28:58.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-22T23:26:35.058Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dataplayer12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-17T15:52:26.000Z","updated_at":"2022-06-17T16:28:50.000Z","dependencies_parsed_at":"2023-05-29T10:10:17.124Z","dependency_job_id":null,"html_url":"https://github.com/dataplayer12/sched_deadline","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplayer12%2Fsched_deadline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplayer12%2Fsched_deadline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplayer12%2Fsched_deadline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplayer12%2Fsched_deadline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dataplayer12","download_url":"https://codeload.github.com/dataplayer12/sched_deadline/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243859905,"owners_count":20359609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T05:28:25.066Z","updated_at":"2025-03-16T11:25:49.018Z","avatar_url":"https://github.com/dataplayer12.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sched_deadline\nMinimal example of using SCHED_DEADLINE for realtime scheduling of C programs in Linux\n\n\n## What is this?\nSince version 3.14, the Linux kernel supports a new deadline scheduler, but it is not easy to use.\nThis repo presents a simple way to use the `sched_getattr` and `sched_setattr` syscalls.\nSee [this](https://stackoverflow.com/questions/50082317/is-sched-deadline-officially-supported-in-ubuntu-16-04) SO issue for more details.\n\n## How to use\nJust include `sd_hdsr.h` into your own C program and use `sched_getattr` and `sched_setattr` as described in the [manpages](https://man7.org/linux/man-pages/man2/sched_setattr.2.html).\n\n## Compiling test example\n\nCompile with\n```Shell\ngcc sd_hdr.h main.c -lpthread -lm -o a.out\nsudo ./a.out\n```\n\n## Caveats\n1. If you are working with periods smaller than 1 millisecond, you need to enable the high resolution tick for the scheduler.\n\n```Shell\nsudo su\ncd /sys/kernel/debug\necho HRTICK \u003e sched_features\n```\n\nThis needs to be done every time the system boots, so write a script to do that.\n\n2. To use `SHCED_DEADLINE` the user application needs to have superuser permissions. If you do not use `sudo`, the application will run as fast as possible.\n3. As explained in the references below, the kernel does not allow the application to take up more than 95% od runtime every second. Basically, `sched_runtime/sched_deadline \u003c= 0.95`. This is to prevent the system from locking up if the user program goes into an infinite loop because of a bug. If you want to use more than 95% CPU time, you can disable this limitation by\n\n```Shell\nsudo su\ncd /proc/sys/kernel\necho -1 \u003e sched_rt_runtime_us\n```\nBefore doing this, make sure your realtime application is bug free or else your system could become unstable and even crash.\n\n\n## Some nice references\n\n- [Using SCHED_DEADLINE](https://youtu.be/TDR-rgWopgM)\n- [Juri Lelli's talk](https://youtu.be/AmyfSjRMcIY)\n- [Realtime Linux checklist](https://youtu.be/NrjXEaTSyrw)\n- [Kernel documentation](https://docs.kernel.org/scheduler/sched-deadline.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataplayer12%2Fsched_deadline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataplayer12%2Fsched_deadline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataplayer12%2Fsched_deadline/lists"}