{"id":47805280,"url":"https://github.com/sysprog21/thread-metric-benchmark","last_synced_at":"2026-04-03T17:31:58.450Z","repository":{"id":339896629,"uuid":"1163727451","full_name":"sysprog21/thread-metric-benchmark","owner":"sysprog21","description":"Thread-Metric RTOS Test Suite","archived":false,"fork":false,"pushed_at":"2026-03-23T14:41:57.000Z","size":196,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-23T22:36:43.903Z","etag":null,"topics":["benchmarking","memory-allocation","preemptive-multitasking","real-time-systems","rtos","scheduling"],"latest_commit_sha":null,"homepage":"","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/sysprog21.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-22T03:37:36.000Z","updated_at":"2026-03-23T14:41:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sysprog21/thread-metric-benchmark","commit_stats":null,"previous_names":["sysprog21/thread-metric-benchmark"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sysprog21/thread-metric-benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysprog21%2Fthread-metric-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysprog21%2Fthread-metric-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysprog21%2Fthread-metric-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysprog21%2Fthread-metric-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysprog21","download_url":"https://codeload.github.com/sysprog21/thread-metric-benchmark/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysprog21%2Fthread-metric-benchmark/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31366356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T17:13:05.644Z","status":"ssl_error","status_checked_at":"2026-04-03T17:13:04.413Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["benchmarking","memory-allocation","preemptive-multitasking","real-time-systems","rtos","scheduling"],"created_at":"2026-04-03T17:31:57.837Z","updated_at":"2026-04-03T17:31:58.442Z","avatar_url":"https://github.com/sysprog21.png","language":"C","readme":"# Thread-Metric RTOS Test Suite\n\nThread-Metric measures RTOS primitive throughput by counting operations completed\nin a fixed time interval (default 30 seconds). Results enable direct comparison\nacross different RTOS implementations on the same hardware.\n\nOriginally from Microsoft's [ThreadX](https://github.com/eclipse-threadx/threadx)\nrepository, released under the MIT license.\n\n## Tests\n\n| Test | File | What it measures |\n|------|------|--------------------|\n| Basic Processing | `src/basic_processing.c` | Single-thread throughput (baseline for scaling results) |\n| Cooperative Scheduling | `src/cooperative_scheduling.c` | 5 equal-priority threads doing round-robin relinquish |\n| Preemptive Scheduling | `src/preemptive_scheduling.c` | 5 threads at different priorities doing resume/suspend chains |\n| Interrupt Processing | `src/interrupt_processing.c` | Software trap -\u003e ISR posts semaphore -\u003e thread picks it up |\n| Interrupt Preemption | `src/interrupt_preemption_processing.c` | Software trap -\u003e ISR resumes higher-priority thread |\n| Message Processing | `src/message_processing.c` | Single thread send/receive of 4-unsigned-long queue messages |\n| Synchronization | `src/synchronization_processing.c` | Single thread semaphore get/put cycle |\n| Memory Allocation | `src/memory_allocation.c` | Single thread 128-byte block allocate/deallocate cycle |\n\n## Architecture\n\n```\nconfigs/\n  Kconfig               # Build configuration schema (RTOS, target, options)\n  *_defconfig            # Pre-made configurations for each RTOS+target\n\nmk/\n  build.mk               # Toolchain, flags, build directory, verbosity\n\ninclude/\n  tm_api.h               # RTOS-neutral API (14 functions + tm_cause_interrupt)\n\nsrc/\n  *.c                    # One test per file, each defines tm_main()\n\nports/\n  common/\n    cortex-m/            # Shared Cortex-M3 bootstrap for QEMU mps2-an385\n      startup.S          #   Reset handler, BSS/data init, semihosting setup\n      vector_table.c     #   Default NVIC handlers (weak aliases)\n      mps2_an385.ld      #   Linker script (4 MB FLASH + 4 MB SRAM)\n  threadx/               # ThreadX porting layer\n    tm_port.c            #   14-function API implementation\n    main.c               #   Entry point\n    posix-host/          #   POSIX simulator config (Linux/macOS)\n    cortex-m/            #   Cortex-M3 QEMU support (SVC dispatch, SysTick)\n  freertos/              # FreeRTOS porting layer\n    tm_port.c            #   14-function API implementation\n    main.c               #   Entry point\n    posix-host/          #   POSIX simulator config (FreeRTOSConfig.h)\n    cortex-m/            #   Cortex-M3 QEMU support (NVIC IRQ dispatch)\n\nscripts/\n  qemu-run.sh            # QEMU runner with semihosting + timeout\n```\n\nTwo layers, one boundary: tests call the API in `tm_api.h`, the porting layer\nmaps those calls to real RTOS primitives. Each binary links exactly one test\nsource file.\n\n## Supported RTOS Ports\n\n| RTOS | POSIX Host | Cortex-M QEMU | Interrupt Tests |\n|------|-----------|---------------|-----------------|\n| ThreadX | yes | yes (mps2-an385) | yes |\n| FreeRTOS | yes | yes (mps2-an385) | yes |\n\nBoth ports have been tested with all 8 tests on both targets (`make check`).\n\n## Porting Layer\n\nImplement the 14 functions declared in `tm_api.h` plus `tm_cause_interrupt()`.\nSee `ports/threadx/tm_port.c` or `ports/freertos/tm_port.c` for references.\n\nRequirements for fair benchmarking:\n- Functions must be real calls, not macros\n- `tm_thread_sleep` needs a 10 ms periodic tick source\n- Queue messages are `4 * sizeof(unsigned long)` bytes (16 on ILP32, 32 on LP64)\n- Memory pool blocks are 128 bytes\n- No cache locking of test or RTOS code regions\n- Use 30-second measurement intervals\n\n## Building\n\nThe build system uses [Kconfiglib](https://github.com/sysprog21/Kconfiglib)\nfor RTOS and target selection.\nKconfiglib is downloaded automatically on first use.\n\n### Quick start\n\nConfigure once, then build:\n```shell\nmake defconfig          # Apply default config (ThreadX + POSIX host)\nmake                    # Build all test binaries\n```\n\nOr configure and build in a single command:\n```shell\nmake defconfig all\n```\n\n### Selecting an RTOS and target\n\nNamed defconfig files provide pre-made configurations:\n```shell\nmake threadx_posix_defconfig        # ThreadX + POSIX host\nmake threadx_cortex_m_defconfig     # ThreadX + Cortex-M3 QEMU\nmake freertos_posix_defconfig       # FreeRTOS + POSIX host\nmake freertos_cortex_m_defconfig    # FreeRTOS + Cortex-M3 QEMU\n```\n\nFor interactive configuration with a menu interface:\n```shell\nmake config\n```\n\nThe RTOS kernel is cloned automatically on first build (ThreadX from\neclipse-threadx/threadx, FreeRTOS from FreeRTOS/FreeRTOS-Kernel).\n\n### Common targets\n\n```shell\nmake                    # Build all test binaries\nmake tm_basic_processing # Build a single test\nmake check              # Build with 3 s intervals + 1 cycle, run all tests\nmake clean              # Remove binaries and build directory\nmake distclean          # Also remove .config, cloned RTOS trees, Kconfiglib\nmake help               # Show all available targets and overrides\n```\n\n### POSIX host\n\nThreadX POSIX port uses `pthread_setschedparam`, which requires elevated\nprivileges on Linux:\n```shell\nsudo ./tm_basic_processing\n```\n\nFreeRTOS POSIX port runs without `sudo`.\n\n### Cortex-M QEMU\n\nRequires `arm-none-eabi-gcc` and `qemu-system-arm`. The build system\nauto-sets `CROSS_COMPILE=arm-none-eabi-` and validates the cross-compiler\nexists before building. Override with an explicit path if needed:\n```shell\nmake CROSS_COMPILE=/opt/toolchain/arm-none-eabi/bin/arm-none-eabi-\n```\n\nRun under QEMU (auto-terminates via semihosting after one report):\n```shell\nmake run\n```\n\nOr run the QEMU script directly:\n```shell\nscripts/qemu-run.sh tm_basic_processing -semihosting-config enable=on,target=native\n```\n\n### Build options\n\nKconfig options can be set via `make config` (interactive) or by editing\n`.config` directly:\n\n| Option | Default | Effect |\n|--------|---------|--------|\n| `CONFIG_TEST_DURATION` | 30 | Reporting interval in seconds |\n| `CONFIG_TEST_CYCLES` | 0 | Reports before exit (0 = infinite) |\n| `CONFIG_OPTIMIZE_SIZE` | n | Use `-Os` instead of `-O2` |\n| `CONFIG_DEBUG_SYMBOLS` | n | Add `-g` |\n| `CONFIG_SANITIZERS` | n | Enable ASan/UBSan (POSIX host only) |\n\nCommand-line overrides still work for test parameters:\n```shell\nmake TM_TEST_DURATION=5 TM_TEST_CYCLES=1\n```\n\nVerbose build output:\n```shell\nmake V=1\n```\n\n## Adding a New RTOS Port\n\n1. Create `ports/\u003crtos\u003e/tm_port.c` implementing the 14 functions in `tm_api.h`\n2. Create `ports/\u003crtos\u003e/main.c` with RTOS-specific startup\n3. For POSIX host: provide configuration headers in `ports/\u003crtos\u003e/posix-host/`\n4. For Cortex-M QEMU: provide RTOS config and ISR dispatch in\n   `ports/\u003crtos\u003e/cortex-m/`; the shared bootstrap in `ports/common/cortex-m/`\n   handles reset, vector table, and linker script\n5. Add a `CONFIG_RTOS_\u003cNAME\u003e` choice entry in `configs/Kconfig`\n6. Add an `ifeq ($(CONFIG_RTOS_\u003cNAME\u003e),y)` block in the Makefile\n7. Create `configs/\u003crtos\u003e_posix_defconfig` and `configs/\u003crtos\u003e_cortex_m_defconfig`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysprog21%2Fthread-metric-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysprog21%2Fthread-metric-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysprog21%2Fthread-metric-benchmark/lists"}