Opening a file · operating system
Not infrastructure: what happens when an app opens a file, through the layers of a desktop OS, with privilege drawn as a boundary and every crossing guarded.
The CityScript
This is all there is to it. Change it in the editor and the city redraws.
%% What happens when an app opens a file, on the layers every modern desktop system shares.
%% Not infrastructure, so it asks for the operating system pack (packs=os). It names no company's system:
%% rename the rooms for the one you mean. A boundary is privilege: what runs in the kernel may do
%% anything, so every call that crosses into it or out to the hardware is guarded.
city 46x30 packs=os
district apps "Applications" 3,4..16,9
district service-layer "System services" 21,4..27,9
district kernelside "Kernel and drivers" 3,13..15,18
district machine "Hardware" 20,13..27,18
building editor program at 4,5 "Text editor" owner="App maker"
floor editor.f "Running"
room editor.proc process "Editor process"
room editor.doc memory "Open document"
building browser program at 9,5 "Web browser" owner="App maker"
floor browser.f "Running"
room browser.proc process "Browser process"
building services program at 22,5 "System services" owner="System maker"
floor services.f "Running in the background"
room services.win process "Window server"
room services.perms service "Permission checks"
building kernel kernel at 4,14 "Kernel" owner="System maker"
floor kernel.api "The door in"
room kernel.syscalls syscall "System calls"
floor kernel.core "The work"
room kernel.sched scheduler "Scheduler"
room kernel.vm memory "Virtual memory"
room kernel.fs files "File system"
building drivers kernel at 9,14 "Drivers" owner="System and chip makers"
floor drivers.f "Talking to devices"
room drivers.disk driver "Disk driver"
room drivers.display driver "Display driver"
building hardware chip at 21,14 "Hardware" owner="Chip makers"
floor hardware.compute "Compute"
room hardware.cpu device "Processor"
room hardware.ram device "Memory chips"
floor hardware.io "Input and output"
room hardware.ssd device "Solid state disk"
room hardware.screen device "Screen"
boundary privileged "Runs with full privilege" members=kernel,drivers
gate user at 0,6 "The user"
road user -> editor
link editor.proc -> services.perms "may I?"
link editor.proc -> kernel.syscalls "open a file" variant=security
link browser.proc -> kernel.syscalls "open a connection" variant=security
link services.win -> kernel.syscalls "draw a window" variant=security
link kernel.syscalls -> kernel.fs "find the path"
link kernel.fs -> kernel.vm "keep the pages"
link kernel.vm -> editor.doc "map into the app" variant=security
link kernel.sched -> editor.proc "give it the processor" variant=security
link kernel.sched -> hardware.cpu "run on" variant=security
link kernel.fs -> drivers.disk "read blocks"
link drivers.disk -> hardware.ssd "read" variant=security
link drivers.display -> hardware.screen "pixels" variant=security
%% The way of an open call, down to the disk and back, and of a picture on the screen.
pipeline open "Opening a file" editor -> [ask] -> kernel -> [check] -> drivers -> [read] -> hardware -> [bring-back] -> editor
step editor "You choose Open in an app"
step kernel "The system checks that you may read the file"
step drivers "The disk's driver finds the file"
step hardware "The disk hands over the bytes"
step editor "The file appears in the app"
pipeline draw "Drawing a window" editor -> [paint] -> services -> [compose] -> drivers -> [show] -> hardware
step editor "An app wants to show a window"
step services "The window manager lays it out with the others"
step drivers "The screen's driver prepares the picture"
step hardware "The screen shows it"