Stdlib module kernel/sync.vitl

This page is a wiki-style reference for one concrete stdlib file. It explains what the file owns, where it fits in the family, and how to decide whether this is the right surface to depend on.

Visual portrait of kernel/sync.vitl
Wiki-style portrait for kernel/sync.vitl.

Family: kernel

Kind: public stdlib surface

Page style: this reference follows the same “encyclopedic card + portrait + usage contract” logic as the keyword pages, but for stdlib modules.

Summary

Overview

FieldValue
Pathkernel/sync.vitl
Familykernel
Kindpublic stdlib surface
Line count230
Declared procedures34
Declared forms/picks6

`kernel/sync.vitl` is a public stdlib surface inside the `kernel` family. It should be read as one focused slice of the broader family responsibility: System-facing runtime helpers such as process, scheduler, threads, sync, users, signals, network, device, and memory.

Purpose

This file should be chosen because of responsibility, not because its name “sounds close enough”. Inside the kernel family, it carries one focused part of the contract and keeps that responsibility separate from neighboring concerns.

  • A service manager may use scheduler, process, and signals while keeping policy in separate code.
  • A network-facing runtime should explain why it depends on kernel surfaces instead of lighter families.

Taxonomy

Think of this page as a generated encyclopedia entry rather than a hand-written tutorial. The goal is to show what kind of module this is, how dense it is, and what reading strategy makes sense before depending on it.

  • Large algorithm surface: this file exposes many procedures and likely acts as a domain toolkit rather than a single thin wrapper.
  • Owns domain vocabulary: the module declares data shapes in addition to executable helpers, so its types are part of the contract.
  • Has tuning constants: part of the module behavior is controlled by named constants that document default precision, limits, or policy.
  • Minimal top-level dependencies: the module reads as mostly self-contained from its opening declarations.
  • Explicit export surface: the file ends with visible export declarations instead of relying only on implicit namespace discovery.

Implementation profile

This profile is inferred directly from the source text. It does not replace reading the file, but it tells you quickly whether the module is mostly declarative, loop-heavy, branch-heavy, or organized around many small exits.

SignalCountWhat it suggests
if0Branching density and local decision-making.
while0Loop-heavy or iterative implementation style.
for0Collection-style traversal at source level.
match0Variant-driven branching or grammar-style decoding.
let0Local state and intermediate value density.
give34Number of explicit exit points and result shaping.

Top-level API inventory

SurfaceItems
Procedurespthread_mutex_create, pthread_mutex_lock, pthread_mutex_unlock, pthread_mutex_trylock, pthread_mutex_timedlock, pthread_mutex_destroy, sem_create, sem_wait, sem_trywait, sem_timedwait, sem_post, sem_getvalue
FormsMutex, Semaphore, Lock, CondVar, Barrier, RWLock
Picksnone declared at top level
ConstantsPTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK
Exports*

Imported surfaces

This file does not advertise a top-level `use` surface in its opening declarations. That often means it is either self-contained or an aggregation layer.

Position in family

This file is module 10 of 12 in the kernel family when ordered by path. By procedure count it ranks 4, and by line count it ranks 4. Those ranks are useful as rough signals of breadth, not as quality judgments.

Declaration map

The declaration map turns raw source into a scan-friendly catalog. It is useful when the file is large enough that a reader wants to orient by kinds of surfaces first.

LineNameKindRole
1vitte/kernel_name/syncspaceDeclares the namespace that anchors this file in the stdlib tree.
9MutexformIntroduces a structured data shape that other procedures can exchange.
14SemaphoreformIntroduces a structured data shape that other procedures can exchange.
19LockformIntroduces a structured data shape that other procedures can exchange.
24CondVarformIntroduces a structured data shape that other procedures can exchange.
29BarrierformIntroduces a structured data shape that other procedures can exchange.
34RWLockformIntroduces a structured data shape that other procedures can exchange.
39PTHREAD_MUTEX_NORMALconstDefines a named constant reused across the module.
40PTHREAD_MUTEX_RECURSIVEconstDefines a named constant reused across the module.
41PTHREAD_MUTEX_ERRORCHECKconstDefines a named constant reused across the module.
47pthread_mutex_createprocOwns coordination, scheduling, or concurrency behavior.
51pthread_mutex_lockprocOwns coordination, scheduling, or concurrency behavior.
56pthread_mutex_unlockprocOwns coordination, scheduling, or concurrency behavior.
61pthread_mutex_trylockprocOwns coordination, scheduling, or concurrency behavior.
66pthread_mutex_timedlockprocOwns coordination, scheduling, or concurrency behavior.
71pthread_mutex_destroyprocOwns coordination, scheduling, or concurrency behavior.
80sem_createprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
84sem_waitprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
89sem_trywaitprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
94sem_timedwaitprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
99sem_postprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
104sem_getvalueprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
109sem_destroyprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
118pthread_cond_createprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
122pthread_cond_waitprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
127pthread_cond_timedwaitprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
132pthread_cond_signalprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
137pthread_cond_broadcastprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
142pthread_cond_destroyprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
151pthread_barrier_createprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
155pthread_barrier_waitprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
160pthread_barrier_destroyprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
169pthread_rwlock_createprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
173pthread_rwlock_rdlockprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
178pthread_rwlock_wrlockprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
183pthread_rwlock_tryrdlockprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
188pthread_rwlock_trywrlockprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
193pthread_rwlock_unlockprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
198pthread_rwlock_destroyprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
207pthread_spin_createprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
211pthread_spin_lockprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
216pthread_spin_unlockprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
221pthread_spin_trylockprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
226pthread_spin_destroyprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.

The table is exhaustive for top-level declarations of the selected kinds. This file declares 44 matching surfaces.

Representative signatures

These signatures are shown in source order so the page keeps the feel of a reference manual, not just a keyword cloud.

  • form Mutex { (line 9)
  • form Semaphore { (line 14)
  • form Lock { (line 19)
  • form CondVar { (line 24)
  • form Barrier { (line 29)
  • form RWLock { (line 34)
  • const PTHREAD_MUTEX_NORMAL: i32 = 0 (line 39)
  • const PTHREAD_MUTEX_RECURSIVE: i32 = 1 (line 40)
  • const PTHREAD_MUTEX_ERRORCHECK: i32 = 2 (line 41)
  • proc pthread_mutex_create() -> Mutex { (line 47)
  • proc pthread_mutex_lock(mutex: Mutex) -> int { (line 51)
  • proc pthread_mutex_unlock(mutex: Mutex) -> int { (line 56)
  • proc pthread_mutex_trylock(mutex: Mutex) -> int { (line 61)
  • proc pthread_mutex_timedlock(mutex: Mutex, timeout_ms: i64) -> int { (line 66)
  • proc pthread_mutex_destroy(mutex: Mutex) -> int { (line 71)
  • proc sem_create(initial_value: int) -> Semaphore { (line 80)
  • proc sem_wait(sem: Semaphore) -> int { (line 84)
  • proc sem_trywait(sem: Semaphore) -> int { (line 89)

The list is intentionally capped here; the source file declares 43 matching signatures in total.

How to use this module

Start by reading the file as an ownership boundary. Ask three questions: what enters this module, what stable types or procedures it exports, and what adjacent module should stay outside of it.

  1. Read space and top-level imports first so the ownership boundary of kernel/sync.vitl is explicit.
  2. Scan constants before procedures; they often encode precision, limits, or policy assumptions that explain later behavior.
  3. Read declared forms and picks before algorithms so the data vocabulary is stable in your head.
  4. Traverse procedures in source order; the early helpers usually explain the naming and numeric conventions used later.
  5. Use the source landmarks section below as a table of contents when the file is large.

User example

This example is generated from the actual stdlib module surface. Its job is not to be the smallest snippet possible; its job is to show a realistic consumer-shaped file that exercises the module and mirrors the language keywords the module itself relies on.

space demo/kernel_sync
const SAMPLE_LABEL: string = "demo"
form UserReport {
  label: string,
  ready: bool
}
proc run_example() -> UserReport {
    give UserReport { label: "ok", ready: ready }
}
export run_example

Keyword coverage

This table makes the “all keywords of the module” requirement auditable. It compares the detected Vitte keywords in the source file with the generated consumer example above.

KeywordPresent in module sourceUsed in generated user example
spaceyesyes
constyesyes
formyesyes
procyesyes
giveyesyes
atyesno
exportyesyes

Keywords still not exercised directly in the generated snippet: at. The page still lists them here so the gap is visible.

Source shape

space vitte/kernel_name/sync
// Mutex type
form Mutex {
  handle: i64
}
// Semaphore type
form Semaphore {
  handle: i64
}
// Lock type

The excerpt is not meant to replace the file. It exists to make the module recognizable at first glance, the same way a Wikipedia infobox helps the reader orient before reading the whole article.

Source landmarks

Large files are easier to retain when they have visible landmarks. When the source contains explicit section banners, they are surfaced here; otherwise the first major declarations are used as anchors.

  • Synchronization — Mutexes, Semaphores, Locks / Thread synchronization primitives
  • Mutex Operations
  • Semaphore Operations
  • Condition Variable Operations
  • Barrier Operations
  • Reader-Writer Lock Operations
  • Spin Lock Operations

Source organization

When a file carries its own internal chaptering, those chapters usually reveal the intended reading order better than a flat symbol list. This section reconstructs that organization from the source itself.

Opening declarations

Top-level items: 1. Procedures: 0. Data surfaces: 0. Constants: 0.

First visible names: vitte/kernel_name/sync

Synchronization — Mutexes, Semaphores, Locks / Thread synchronization primitives

Top-level items: 9. Procedures: 0. Data surfaces: 6. Constants: 3.

First visible names: Mutex, Semaphore, Lock, CondVar, Barrier, RWLock, PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK

Mutex Operations

Top-level items: 6. Procedures: 6. Data surfaces: 0. Constants: 0.

First visible names: pthread_mutex_create, pthread_mutex_lock, pthread_mutex_unlock, pthread_mutex_trylock, pthread_mutex_timedlock, pthread_mutex_destroy

Semaphore Operations

Top-level items: 7. Procedures: 7. Data surfaces: 0. Constants: 0.

First visible names: sem_create, sem_wait, sem_trywait, sem_timedwait, sem_post, sem_getvalue, sem_destroy

Condition Variable Operations

Top-level items: 6. Procedures: 6. Data surfaces: 0. Constants: 0.

First visible names: pthread_cond_create, pthread_cond_wait, pthread_cond_timedwait, pthread_cond_signal, pthread_cond_broadcast, pthread_cond_destroy

Barrier Operations

Top-level items: 3. Procedures: 3. Data surfaces: 0. Constants: 0.

First visible names: pthread_barrier_create, pthread_barrier_wait, pthread_barrier_destroy

Reader-Writer Lock Operations

Top-level items: 7. Procedures: 7. Data surfaces: 0. Constants: 0.

First visible names: pthread_rwlock_create, pthread_rwlock_rdlock, pthread_rwlock_wrlock, pthread_rwlock_tryrdlock, pthread_rwlock_trywrlock, pthread_rwlock_unlock, pthread_rwlock_destroy

Spin Lock Operations

Top-level items: 6. Procedures: 5. Data surfaces: 0. Constants: 0.

First visible names: pthread_spin_create, pthread_spin_lock, pthread_spin_unlock, pthread_spin_trylock, pthread_spin_destroy, *

Complete API catalog

This catalog is the exhaustive file-level index for the module. It is intentionally closer to a generated encyclopedia appendix than to a tutorial summary.

Constants

LineNameSignatureRole
39PTHREAD_MUTEX_NORMALconst PTHREAD_MUTEX_NORMAL: i32 = 0Defines a named constant reused across the module.
40PTHREAD_MUTEX_RECURSIVEconst PTHREAD_MUTEX_RECURSIVE: i32 = 1Defines a named constant reused across the module.
41PTHREAD_MUTEX_ERRORCHECKconst PTHREAD_MUTEX_ERRORCHECK: i32 = 2Defines a named constant reused across the module.

Data surfaces

LineNameSignatureRole
9Mutexform Mutex {Introduces a structured data shape that other procedures can exchange.
14Semaphoreform Semaphore {Introduces a structured data shape that other procedures can exchange.
19Lockform Lock {Introduces a structured data shape that other procedures can exchange.
24CondVarform CondVar {Introduces a structured data shape that other procedures can exchange.
29Barrierform Barrier {Introduces a structured data shape that other procedures can exchange.
34RWLockform RWLock {Introduces a structured data shape that other procedures can exchange.

Procedures

LineNameSignatureRole
47pthread_mutex_createproc pthread_mutex_create() -> Mutex {Owns coordination, scheduling, or concurrency behavior.
51pthread_mutex_lockproc pthread_mutex_lock(mutex: Mutex) -> int {Owns coordination, scheduling, or concurrency behavior.
56pthread_mutex_unlockproc pthread_mutex_unlock(mutex: Mutex) -> int {Owns coordination, scheduling, or concurrency behavior.
61pthread_mutex_trylockproc pthread_mutex_trylock(mutex: Mutex) -> int {Owns coordination, scheduling, or concurrency behavior.
66pthread_mutex_timedlockproc pthread_mutex_timedlock(mutex: Mutex, timeout_ms: i64) -> int {Owns coordination, scheduling, or concurrency behavior.
71pthread_mutex_destroyproc pthread_mutex_destroy(mutex: Mutex) -> int {Owns coordination, scheduling, or concurrency behavior.
80sem_createproc sem_create(initial_value: int) -> Semaphore {Represents one top-level surface in the file contract and should be read as part of the module boundary.
84sem_waitproc sem_wait(sem: Semaphore) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
89sem_trywaitproc sem_trywait(sem: Semaphore) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
94sem_timedwaitproc sem_timedwait(sem: Semaphore, timeout_ms: i64) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
99sem_postproc sem_post(sem: Semaphore) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
104sem_getvalueproc sem_getvalue(sem: Semaphore) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
109sem_destroyproc sem_destroy(sem: Semaphore) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
118pthread_cond_createproc pthread_cond_create() -> CondVar {Represents one top-level surface in the file contract and should be read as part of the module boundary.
122pthread_cond_waitproc pthread_cond_wait(cond: CondVar, mutex: Mutex) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
127pthread_cond_timedwaitproc pthread_cond_timedwait(cond: CondVar, mutex: Mutex, timeout_ms: i64) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
132pthread_cond_signalproc pthread_cond_signal(cond: CondVar) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
137pthread_cond_broadcastproc pthread_cond_broadcast(cond: CondVar) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
142pthread_cond_destroyproc pthread_cond_destroy(cond: CondVar) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
151pthread_barrier_createproc pthread_barrier_create(count: int) -> Barrier {Represents one top-level surface in the file contract and should be read as part of the module boundary.
155pthread_barrier_waitproc pthread_barrier_wait(barrier: Barrier) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
160pthread_barrier_destroyproc pthread_barrier_destroy(barrier: Barrier) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
169pthread_rwlock_createproc pthread_rwlock_create() -> RWLock {Represents one top-level surface in the file contract and should be read as part of the module boundary.
173pthread_rwlock_rdlockproc pthread_rwlock_rdlock(rwlock: RWLock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
178pthread_rwlock_wrlockproc pthread_rwlock_wrlock(rwlock: RWLock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
183pthread_rwlock_tryrdlockproc pthread_rwlock_tryrdlock(rwlock: RWLock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
188pthread_rwlock_trywrlockproc pthread_rwlock_trywrlock(rwlock: RWLock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
193pthread_rwlock_unlockproc pthread_rwlock_unlock(rwlock: RWLock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
198pthread_rwlock_destroyproc pthread_rwlock_destroy(rwlock: RWLock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
207pthread_spin_createproc pthread_spin_create() -> Lock {Represents one top-level surface in the file contract and should be read as part of the module boundary.
211pthread_spin_lockproc pthread_spin_lock(spinlock: Lock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
216pthread_spin_unlockproc pthread_spin_unlock(spinlock: Lock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
221pthread_spin_trylockproc pthread_spin_trylock(spinlock: Lock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
226pthread_spin_destroyproc pthread_spin_destroy(spinlock: Lock) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.

Exports

LineNameSignatureRole
230*export *Re-exports surfaces that the module wants to expose as part of its public boundary.

Integration boundaries

Within kernel, this file should remain focused. If a future helper changes the host boundary, scheduling boundary, or data-shape boundary, it probably belongs in a neighbor module instead of being added here by convenience.

  • Family responsibility: System-facing runtime helpers such as process, scheduler, threads, sync, users, signals, network, device, and memory.
  • Family architecture role: Use `kernel` when the program explicitly models system services, scheduling, process behavior, or device-facing coordination.

Composition guidance

Choose this module when

  • Choose kernel/sync.vitl when the main question is owned by this module rather than by transport, storage, orchestration, or user-interface code.
  • A service manager may use scheduler, process, and signals while keeping policy in separate code.
  • A network-facing runtime should explain why it depends on kernel surfaces instead of lighter families.

Pause before extending it when

  • Avoid extending this file when the new helper mostly changes the boundary to host I/O, runtime coordination, or foreign integration instead of staying inside kernel.
  • Check nearby modules such as kernel/device.vitl, kernel/fileio.vitl, kernel/interrupt.vitl before adding convenience wrappers here.

Relationship table

This table keeps the page closer to a real encyclopedia entry: a module is easier to understand when compared with its nearest alternatives in the same family.

NeighborProceduresData surfacesWhy compare it
kernel/device.vitl00Shares the same family boundary but carries a distinct slice of responsibility.
kernel/fileio.vitl442Shares the same family boundary but carries a distinct slice of responsibility.
kernel/interrupt.vitl90Shares the same family boundary but carries a distinct slice of responsibility.
kernel/memory.vitl181Shares the same family boundary but carries a distinct slice of responsibility.
kernel/network.vitl424Shares the same family boundary but carries a distinct slice of responsibility.
kernel/process.vitl142Shares the same family boundary but carries a distinct slice of responsibility.
kernel/scheduler.vitl10Shares the same family boundary but carries a distinct slice of responsibility.
kernel/signals.vitl181Shares the same family boundary but carries a distinct slice of responsibility.

Neighbor modules