{"id":16984642,"url":"https://github.com/not-nik/coop","last_synced_at":"2026-02-04T01:39:45.215Z","repository":{"id":104028775,"uuid":"327484308","full_name":"Not-Nik/coop","owner":"Not-Nik","description":"API and ABI independent, user-space multitasking","archived":false,"fork":false,"pushed_at":"2022-03-08T16:18:07.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T00:56:34.298Z","etag":null,"topics":["async","coroutines","multitasking","multithreading","x86-64"],"latest_commit_sha":null,"homepage":"https://notnik.cc/posts/async/","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/Not-Nik.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":"2021-01-07T02:43:15.000Z","updated_at":"2024-01-04T18:26:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"0ae32844-a1b7-4161-bda6-c99973364468","html_url":"https://github.com/Not-Nik/coop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Not-Nik/coop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Not-Nik%2Fcoop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Not-Nik%2Fcoop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Not-Nik%2Fcoop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Not-Nik%2Fcoop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Not-Nik","download_url":"https://codeload.github.com/Not-Nik/coop/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Not-Nik%2Fcoop/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29063974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T00:26:14.114Z","status":"ssl_error","status_checked_at":"2026-02-04T00:23:06.435Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["async","coroutines","multitasking","multithreading","x86-64"],"created_at":"2024-10-14T02:33:09.958Z","updated_at":"2026-02-04T01:39:45.195Z","avatar_url":"https://github.com/Not-Nik.png","language":"C","readme":"# coop\nCoop is an experimental asynchronous multitasking scheduler that tries to\nrun everywhere. It has literally no run time dependencies except for a\nproper x86_64/amd64  machine set to long mode. It's only build-time\ndependency is a C compiler supporting GCC inline assembly. Technically, \ncoop should run, and work, on everything you can compile to, including\nbaremetal and even Windows.\n\nAdditionally, if you want to use coop while staying sane and stack\noverflow-less you will need some memory allocation function like\n`malloc()` and if you want to regain some of you precious memory\nalso one like `free()`.\n\n## Usage example\n\n```c\n#include \u003cstdio.h\u003e\n#include \u003cstdlib.h\u003e\n\n#include \"lib/coop.h\"\n\nvoid my_async_func() {\n    puts(\"Func1: 1\");\n    yield;\n    puts(\"Func1: 2\");\n    dump;\n}\n\nvoid my_async_func2() {\n    puts(\"Func2: 1\");\n    yield;\n    puts(\"Func2: 2\");\n    dump;\n}\n\nint main() {\n    coop_context ctx = make_context();\n    task_t t1 = {0}, t2 = {0};\n    coop_stack s1 = {.size = 4096, .stack_bottom = malloc(4096)};\n    coop_stack s2 = {.size = 4096, .stack_bottom = malloc(4096)};\n    add_task(\u0026ctx, \u0026t1, s1, my_async_func);\n    add_task(\u0026ctx, \u0026t2, s2, my_async_func2);\n    start(\u0026ctx);\n    free(s1.stack_bottom);\n    free(s2.stack_bottom);\n    return 0;\n}\n```\n\n## Pitfalls\n\u003e Most importantly coop isn't tested further than what's in `test.c`\n\ncoop does have two more semi-runtime dependency. Your compiler has to push\nit's rbp value to the stack. If it doesn't, you will get at least the last\nvariable created before yielding control, or, if you don't have a variable,\nthe return pointer, overwritten, both of which can cause very bad things to\nhappen.\nAdditionally, the ABI you are using can't consider RAX and RDX nonvolatile\n(callee-saved), since coop a) uses these registers internally and therefore\nb) doesn't  save them. Luckily this is a) true for the two major ABI's and\nb) nobody  would create such an ABI because these registers are used by \nboth the `div` and `idiv` instruction.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnot-nik%2Fcoop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnot-nik%2Fcoop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnot-nik%2Fcoop/lists"}