This document provides detailed reference for the placeholderOS kernel API functions.
Initializes the kernel with boot flags.
Parameters:
options(table, optional): Boot configuration optionsno_shell(boolean): If true, disables the default shell interface
Initializes and starts the kernel with boot flags.
Parameters:
options(table, optional): Boot configuration options (same askernel.init())
Creates a new process.
Parameters:
func(function): The coroutine function to runname(string): Process nameuser(string): Owner usernamepermissions(table): Array of permission strings
Returns: Process ID (number)
Gets process information.
Parameters:
pid(number): Process ID
Returns: Process table or nil
Lists all processes.
Returns: Array of process info tables
Kills a process.
Parameters:
pid(number): Process ID to kill
This document describes the public kernel API. The runtime implementation now lives at src/api/kernel.lua. For backward compatibility, require("src.kernel") continues to work and returns the same API (a small shim requires the new module).
Important: the kernel API is guarded. Many functions will return (nil, err) or (false, err) when the calling process does not have the required permission. Callers should always check return values for errors.
- API location:
src/api/(public APIs live here). Internal modules remain undersrc/. - Permission model: kernel wrapper functions enforce permission checks.
admin,system, andtrustedare elevated roles. Normal callers cannot perform actions on other users' processes or grant permissions they don't have. - Backwards compatibility: code that does
local kernel = require("src.kernel")will continue to work (the shim forwards tosrc.api.kernel).
Initializes the kernel with boot flags.
Parameters:
options(table, optional): Boot configuration optionsno_shell(boolean): If true, disables the default shell interface
Returns: nothing
Initializes and starts the kernel with boot flags.
Parameters:
options(table, optional): Boot configuration options (same askernel.init())
Returns: nothing
All process management functions perform permission checks. They may return an error string when the caller lacks necessary permissions.
Creates a new process.
Parameters:
func(function): The coroutine function to runname(string): Process nameuser(string): Owner username (optional; defaults to caller's user)permissions(table): Array or map of permission strings (optional)
Returns: pid (number) on success, or nil, err on failure. Common failures include permission-denied when creating a process for another user or granting permissions the caller does not have.
Registers a system process. Requires system permission.
Parameters:
name(string): Process nameuser(string): Owner usernamepermissions(table): Permission array
Returns: pid (number) on success, or nil, err on failure.
Gets process information. Unprivileged callers receive a safe summary. Admin callers see the full permissions table.
Parameters:
pid(number): Process ID
Returns: process info table or nil if not found.
Lists all processes.
Returns: Array of process info tables.
Kills a process. A caller may only kill their own processes unless they have admin.
Parameters:
pid(number): Process ID to kill
Returns: true on success, or false, err on failure.
Suspend or resume processes. Same permission rules as kill_process.
Parameters:
pid(number): Process ID
Returns: true on success, or false, err on failure.
Start/stop the scheduler. These operations require admin permission.
Returns: true on success, or false, err.
Runs one scheduler tick (for manual control). No elevated permissions required.
Returns: scheduler tick result (implementation-defined).
Checks whether the named user has a permission.
Parameters:
username(string): Username to checkpermission(string): Permission name
Returns: boolean
Gets the permissions for a user.
Parameters:
user(string): Username
Returns: table mapping permission -> source or boolean
Assigns a permission to a user. Requires admin.
Parameters:
username(string)permission(string)
Returns: true on success, or false, err.
Create a process and handle permission errors:
local kernel = require("src.kernel") -- shim to src.api.kernel
local pid, err = kernel.create_process(function()
while true do os.sleep(1) end
end, "myproc", "user", {"basic"})
if not pid then
print("Failed to create process:", err)
endThis reference focuses on the public API surface. For internal wiring and module implementation see src/ (internal modules like src.process, src.scheduler, and src.perms).
By default, all src.* modules are protected except for src.api.* and the kernel shim src.kernel. This means user programs should only rely on public APIs under src.api and should not require src.* internal modules directly. To change this policy, edit src/api/secure_loader.lua.