Merge OSEK/VDX OS and/or {BSD OS or POSIX PSE51}
See the Github, please.
We have just begun our work. We look forward to your support, cooperation, advice, and contributions.
GitHub, which originated from FreeBSD,
We welcome your guidance and advice on how best to fork the GitHub repository originating from NetBSD.
Propose
We are planning to integrate the BSD OS and OSEK/VDX OS. The goal is to unify the AUTOSAR Classic Platform and Adaptive Platform, enabling efficient development of both AUTOSAR and non-AUTOSAR vehicle systems from a single OS source, while also facilitating tool improvements. I am considering two approaches. The first approach involves classifying BSD OS interrupt service routines (ISRs) into two categories: “With OS” and “Without OS,” and implementing the Priority Ceiling Protocol. The second approach involves adding POSIX PSE51 functionality to the OSEK/VDX OS. Ideally, I would like to work on both approaches using Docker. We plan to organize the tasks, including environment setup and GitHub registration. What can I start?
Response by ChatGPT
Great — you're planning something very ambitious and strategically meaningful: unifying BSD (Adaptive‐style, POSIX-friendly) with OSEK/VDX (Classic Real-Time deterministic) to support AUTOSAR Classic + Adaptive development from one OS base.
Below is a recommended start plan, broken into actionable phases (0–5), with Docker workflow, repository structure, and short-term milestones. The goal is to get you coding within 7–14 days while ensuring long-term architecture consistency.
📌 Phase 0 — Define the Strategy and Repository Structure (1–2 Days)
Create GitHub Repositories
Repo Name
Purpose
unified-autosar-os
Main integration repo
osek-core
Fork of https://github.com/kaizen-nagoya/osek/
bsd-core-rt
Minimal BSD kernel fork (FreeBSD or NetBSD recommended)
docker-dev-env
Fully reproducible build toolchain
Baseline Documentation Files
Create these initial files:
ROADMAP.md
ARCHITECTURE.md
LICENSE (likely BSD + OSEK requires check)
CONTRIBUTING.md
📌 At this stage, do not write code — define the structure so future contributions don’t drift.
📌 Phase 1 — Docker-Based Development & Emulator Setup (3–5 Days)
Create a runtime environment that supports:
FreeBSD userland tools
GCC/LLVM cross compiler
QEMU for ARM + x86
Real-time test harnesses
Example directory:
docker-dev-env/
├─ Dockerfile
├─ scripts/
│ ├─ build-osek.sh
│ ├─ build-bsd.sh
│ └─ run-qemu.sh
└─ README.md
Target test hardware first:
CPU
Reason
x86_64-QEMU
Easy debugging and POSIX support
ARM Cortex-R or Cortex-M (QEMU)
Closer to automotive safety ECUs
📌 Phase 2 — Choose Initial Integration Path (Parallel Work Allowed)
Approach A: BSD ISR Classification (Your Idea #1)
Goal: Modify BSD HAL scheduler to support:
ISR Type
Meaning
ISR Without OS
Runs in raw native interrupt context (Fast, non-blocking)
ISR With OS
Enters unified scheduler → maps to OSEK or POSIX task
Tasks:
Create ISR_CLASSIFICATION.md
Patch BSD interrupt dispatcher → add OSEK_ISR_FLAG
Implement priority ceiling mutex (OSEK semantics)
Expected Output:
docs/specs/interrupt-bridge-design.md
src/kernel/interrupt_bridge.c
This step brings real-time determinism to BSD.
Approach B: Add POSIX PSE51 to OSEK/VDX (Your Idea #2)
Goal: Make OSEK OS support subset of POSIX threads:
Feature
Status
pthread_create() → OSEK Task
✔ Possible
pthread_mutex() → OSEK Resource
✔ Maps well
clock_nanosleep()
Requires timer HAL
Real-time priority inheritance
Must match AUTOSAR Classic rules
Tasks:
Create compatibility API layer: os_posix_compat/
Define mapping table: POSIX ↔ OSEK API
Example mapping:
POSIX
OSEK
pthread_t
TaskType
pthread_mutex_t
ResourceType
SIGACTION
ISR
📌 Phase 3 — Unified Scheduler Prototype (4–8 Weeks)
Design a dual scheduler:
Component
Source
Static scheduler → Classic AUTOSAR, OSEK
OSEK core
Dynamic scheduler → Adaptive/POSIX threads
BSD core
Deliverable file:
/scheduler/
├─ unified_scheduler.c
├─ osek_scheduler.c
├─ posix_scheduler.c
└─ scheduler_config.json
📌 Phase 4 — Test and CI Pipeline (Continuous)
Use:
RobotFramework or pytest for functional tests
Google Benchmark for scheduling latency
GitHub Actions CI running Docker
Target tests:
Behavior
Expected Output
1ms periodic OSEK Task
≤ jitter 15μs
POSIX thread fairness
Verified with runnable queue logs
Combined ISR performance
No priority inversion
📌 Phase 5 — Documentation + Tooling Integration
Create:
AUTOSAR XML mapping tool
VSCode extension for config
ARXML → Unified configuration generator
Next 7 Days Concrete Action Checklist
Day
Task
Day 1
Create GitHub repos + roadmap
Day 2
Write architecture and integration strategy
Day 3
Build Dockerfile (FreeBSD + OSEK toolchain)
Day 4
Compile both OS in Docker
Day 5
Add QEMU boot test logs
Day 6
Begin ISR classification draft implementation
Day 7
Begin POSIX PSE51 API mapping document
✔ Recommendation: Start with the Docker environment & ISR classification.
It gives you:
deterministic control flow,
low risk,
immediate real hardware testing under QEMU,
and ensures BSD scheduling aligns with OSEK timing philosophy.
If you'd like, I can now generate:
A full Dockerfile
First commit folder layout
GitHub Issue templates
A first PoC code patch
Would you like:
👉 A) Skeleton repo + Docker build system
👉 B) First implementation code (ISR classification + POSIX compatibility stubs)
👉 C) Both A + B in one commit series
Which should we generate first?
Propose
C
Response by ChatGPT
unified-autosar-os — Skeleton repository & PoC
This document provides a ready-to-use repository skeleton, Docker-based dev environment, and first proof-of-concept code for:
ISR classification (With OS / Without OS) bridge
POSIX PSE51 compatibility stubs mapped to OSEK-like primitives
Use this as the initial commit for unified-autosar-os on GitHub.
Repo layout (suggested)
unified-autosar-os/
├─ README.md
├─ ROADMAP.md
├─ ARCHITECTURE.md
├─ LICENSE
├─ .github/
│ ├─ workflows/ci.yml
│ └─ ISSUE_TEMPLATE/
├─ docker-dev-env/
│ ├─ Dockerfile
│ ├─ build.sh
│ └─ run-qemu.sh
├─ osek-core/ (git submodule or fork)
├─ bsd-core-rt/ (git submodule or fork)
├─ src/
│ ├─ interrupt_bridge.c
│ ├─ interrupt_bridge.h
│ ├─ posix_compat.c
│ └─ posix_compat.h
├─ examples/
│ ├─ test_isr.c
│ └─ test_posix.c
└─ ci/
└─ test-scripts/
└─ run_unit_tests.sh
README.md (starter)
unified-autosar-os
Skeleton repo to unify BSD-style POSIX environment with OSEK/VDX Classic RTOS features.
Quick start (development Docker)
# build container
cd docker-dev-env
./build.sh
# start interactive dev shell
./run-qemu.sh # or `docker run -it unified-autosar-os:dev` depending on script
Goals
Provide ISR classification "With OS" / "Without OS"
Implement Priority Ceiling Protocol glue
Provide POSIX PSE51 compatibility layer on top of OSEK primitives
Contributing
Follow CONTRIBUTING.md and use Issues/PRs.
docker-dev-env/Dockerfile
# Simple development Dockerfile for building OSEK and running tests under QEMU
FROM ubuntu:24.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential git cmake pkg-config autoconf automake libtool \
qemu-system-x86 qemu-system-arm qemu-user-static \
gcc-arm-none-eabi gdb-multiarch \
python3 python3-pip sudo curl wget vim \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Create developer user
RUN useradd -ms /bin/bash dev && echo "dev ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/dev
USER dev
WORKDIR /home/dev
# Optional: clone osek and bsd forks (left to user)
# RUN git clone https://github.com/kaizen-nagoya/osek.git osek-core
ENV PATH="/home/dev/.local/bin:${PATH}"
CMD ["/bin/bash"]
docker-dev-env/build.sh
#!/usr/bin/env bash
set -e
IMAGE_NAME=unified-autosar-os:dev
docker build -t $IMAGE_NAME .
echo "Built $IMAGE_NAME"
docker-dev-env/run-qemu.sh
#!/usr/bin/env bash
# Run an interactive dev container (for QEMU, build tools)
IMAGE_NAME=unified-autosar-os:dev
docker run --rm -it --privileged -v "$PWD/..:/workspace" -w /workspace $IMAGE_NAME
.github/workflows/ci.yml (basic)
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 build-essential
- name: Build test binaries
run: |
cd src || exit 1
gcc -std=c11 -Wall -Wextra -O2 -c interrupt_bridge.c posix_compat.c || true
- name: Run unit tests (placeholder)
run: echo "Add real tests"
src/interrupt_bridge.h
#ifndef INTERRUPT_BRIDGE_H
#define INTERRUPT_BRIDGE_H
#include <stdint.h>
typedef enum {
ISR_WITH_OS = 0,
ISR_WITHOUT_OS = 1
} isr_kind_t;
typedef void (*isr_handler_t)(void *arg);
// Register an ISR with classification. Returns 0 on success.
int register_isr(int irq, isr_kind_t kind, isr_handler_t handler, void *arg);
// Unregister
int unregister_isr(int irq);
// Simple priority ceiling resource API (PoC)
typedef int resource_t; // opaque in PoC
int resource_init(resource_t *r, int ceiling_priority);
int resource_get(resource_t *r);
int resource_release(resource_t *r);
#endif // INTERRUPT_BRIDGE_H
src/interrupt_bridge.c
#include "interrupt_bridge.h"
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
// Very small PoC mapping: we maintain a registration table in userland for tests only.
#define MAX_IRQ 256
struct isr_entry {
int used;
isr_kind_t kind;
isr_handler_t handler;
void *arg;
int priority; // lower number == higher priority
};
static struct isr_entry table[MAX_IRQ];
int register_isr(int irq, isr_kind_t kind, isr_handler_t handler, void *arg) {
if (irq < 0 || irq >= MAX_IRQ) return -1;
table[irq].used = 1;
table[irq].kind = kind;
table[irq].handler = handler;
table[irq].arg = arg;
table[irq].priority = 255; // default
printf("[isr] registered irq=%d kind=%d\n", irq, kind);
return 0;
}
int unregister_isr(int irq) {
if (irq < 0 || irq >= MAX_IRQ) return -1;
table[irq].used = 0;
return 0;
}
// Priority ceiling PoC
int resource_init(resource_t *r, int ceiling_priority) {
if (!r) return -1;
*r = ceiling_priority; // PoC: store as int
return 0;
}
// In a full kernel integration this would raise the caller's priority to the ceiling
int resource_get(resource_t *r) {
if (!r) return -1;
// PoC: no-op
return 0;
}
int resource_release(resource_t *r) {
if (!r) return -1;
// PoC: no-op
return 0;
}
// Simulate an IRQ trigger from userspace test
void trigger_irq(int irq) {
if (irq < 0 || irq >= MAX_IRQ) return;
if (!table[irq].used) {
printf("[isr] no handler for irq=%d\n", irq);
return;
}
if (table[irq].kind == ISR_WITHOUT_OS) {
// Call handler directly (simulates non-OS ISR)
table[irq].handler(table[irq].arg);
} else {
// With OS: queue to worker thread (PoC uses pthread)
// In kernel this would schedule a task; here we spawn a thread
pthread_t t;
struct isr_entry *e = &table[irq];
pthread_create(&t, NULL, (void *(*)(void *))e->handler, e->arg);
pthread_detach(t);
}
}
src/posix_compat.h
#ifndef POSIX_COMPAT_H
#define POSIX_COMPAT_H
#include <pthread.h>
// Initialize compatibility layer (map configs)
int posix_compat_init(void);
// Create a POSIX-like thread that maps to OSEK task in full implementation.
int posix_thread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
// Simple wrappers for mutex
int posix_mutex_init(pthread_mutex_t *m);
int posix_mutex_lock(pthread_mutex_t *m);
int posix_mutex_unlock(pthread_mutex_t *m);
#endif // POSIX_COMPAT_H
src/posix_compat.c
#include "posix_compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int posix_compat_init(void) {
// PoC: read configuration or set up translation tables.
printf("[posix_compat] init\n");
return 0;
}
int posix_thread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg) {
// PoC: create a pthread. Real implementation would map to OSEK TaskType
if (!thread || !start_routine) return -1;
return pthread_create(thread, attr, start_routine, arg);
}
int posix_mutex_init(pthread_mutex_t *m) {
if (!m) return -1;
pthread_mutexattr_t a;
pthread_mutexattr_init(&a);
pthread_mutexattr_setprotocol(&a, PTHREAD_PRIO_INHERIT);
int r = pthread_mutex_init(m, &a);
pthread_mutexattr_destroy(&a);
return r;
}
int posix_mutex_lock(pthread_mutex_t *m) {
return pthread_mutex_lock(m);
}
int posix_mutex_unlock(pthread_mutex_t *m) {
return pthread_mutex_unlock(m);
}
examples/test_isr.c
#include "../src/interrupt_bridge.h"
#include <stdio.h>
void fast_isr(void *arg) {
printf("fast_isr: arg=%p\n", arg);
}
void threaded_isr(void *arg) {
printf("threaded_isr start arg=%p\n", arg);
// emulate work
for (int i=0;i<3;i++) {
printf("threaded_isr: step %d\n", i);
}
}
int main(void) {
register_isr(10, ISR_WITHOUT_OS, fast_isr, (void*)0xdeadbeef);
register_isr(11, ISR_WITH_OS, threaded_isr, (void*)0xcafebabe);
trigger_irq(10);
trigger_irq(11);
// wait a bit for threads
sleep(1);
return 0;
}
examples/test_posix.c
#include "../src/posix_compat.h"
#include <stdio.h>
void *worker(void *arg) {
printf("worker running: %s\n", (char*)arg);
return NULL;
}
int main(void) {
posix_compat_init();
pthread_t t;
posix_thread_create(&t, NULL, worker, "hello");
pthread_join(t, NULL);
return 0;
}
ci/test-scripts/run_unit_tests.sh
#!/usr/bin/env bash
set -e
cd $(dirname "$0")/../../src
gcc -std=c11 -Wall -O2 interrupt_bridge.c posix_compat.c -lpthread -o unit_tests
./unit_tests
CONTRIBUTING / ISSUE templates (suggested)
Create .github/ISSUE_TEMPLATE/bug_report.md and feature_request.md with boilerplate.
Next steps (suggested immediate PR contents)
Add this skeleton to a new GitHub repo.
Add osek-core and bsd-core-rt as submodules or document how to fork them.
Push Dockerfile + scripts and verify container builds.
Run examples/test_isr.c and examples/test_posix.c inside the container.
Start a design document in ARCHITECTURE.md describing the kernel-space vs user-space boundary.
Happy to:
generate an initial git commit patch (diff) you can apply locally, or
create a GitHub repo with these files if you provide the organization/name and permission (I cannot perform GitHub actions for you, but I can produce the files and instructions).
Which would you like next?
Discussion