OS Structure and Interface Explained: System Calls, Kernel Designs and Worked Examples

Separate the way programs request OS services from the way those services are organised. Trace a file save and compare two kernel routing models step by step.

KnowledgeGate Team

Exam prep & CS education

Updated 6 Dec 20266 min read
OS Structure and Interface Explained: System Calls, Kernel Designs and Worked Examples

You may be able to name monolithic, layered and microkernel designs, yet still mix up three different ideas: the user interface, the program interface and the internal OS structure. A request from an application to the hardware separates them: saving a 6,000-byte file reveals system-call granularity, while supplied teaching costs compare service placement. An interface says how a caller requests a service; a structure says where that service is implemented and how OS components cooperate.

OS interface and OS structure answer different questions

A command-line interface, graphical interface or batch interface lets a person submit work. A program usually works through libraries and APIs. These expose useful operations to applications, while system calls request protected services from the kernel.

Structure is the organisation of the privileged core and supporting services. It tells us whether file systems, memory management, networking and drivers share kernel space, follow layers, run as servers, or combine these choices.

Question

Example answer

What can the caller ask for?

The user wants save notes.bin; the application calls save_file(...); the system-call interface provides open, write and close.

Where and how is it implemented?

The structure decides where the file-system service and device driver live and how they communicate.

The GATE CS Exam Preparation Courses and Test Series route places these OS concepts within the wider syllabus.

Follow one request from user action to hardware

Trace: user action, library or API, zero or more system calls, system-call entry and validation, kernel service, driver, device, then a return value. A library call may make zero or several system calls.

System-call families include process control (create, wait), file management (open, read, write, close), controlled device I/O, information queries, communication through pipes, shared memory or sockets, and identity or permission checks.

A mode switch is not automatically a process switch. A thread can enter kernel mode and return without the scheduler choosing another process. A blocking request may cause a process switch, but a system call does not guarantee one. The kernel is the privileged core, not necessarily the complete operating system with its libraries, utilities and user interfaces.

System Calls and Dual Mode in OS follows mode-bit changes, protected entry and read() timing at the CPU boundary. The save trace below instead shows how API granularity changes the number of kernel requests.

Worked interface example: save 6,000 bytes and count the calls

Assume the application calls save_file("notes.bin", buffer, 6000). Its contiguous buffer has three 2,000-byte chunks at offsets 0, 2000 and 4000. Every call succeeds fully: open returns descriptor 5, each write returns 2000, and close returns 0.

The one API call expands into five system calls:

  1. open("notes.bin", create/write) returns 5.

  2. write(5, buffer+0, 2000) returns 2000.

  3. write(5, buffer+2000, 2000) returns 2000.

  4. write(5, buffer+4000, 2000) returns 2000.

  5. close(5) returns 0.

Check: 2000 + 2000 + 2000 = 6000.

The following costs are classroom inputs, not machine measurements. A complete system-call round trip costs 0.8 microseconds, and byte handling costs 0.002 microseconds per byte. Exclude file-system lookup, storage, caching, interrupts and scheduling.

  • Call cost: 5 x 0.8 = 4.0 microseconds.

  • Byte cost: 6000 x 0.002 = 12.0 microseconds.

  • Simplified total: 4.0 + 12.0 = 16.0 microseconds.

If one 6,000-byte write handles the same buffer, the sequence is open, write, close. Three calls cost 3 x 0.8 = 2.4 microseconds; byte cost stays 12.0 microseconds; total is 14.4 microseconds. The supplied saving is 16.0 - 14.4 = 1.6 microseconds. This teaches interface granularity, not real storage performance.

Interface trace shows save_file writing 6000 bytes through fd 5 in three 2000-byte writes, with a 16.0 versus 14.4 microsecond batched comparison.

Compare monolithic, layered, microkernel, modular and hybrid structures

Structure

Service placement

Communication path

Main strength

Main risk or cost

Monolithic

Major services share one privileged address space

Direct internal calls

Direct cooperation

A fault can affect shared kernel space

Layered

Components occupy defined logical layers

Each layer uses lower-layer services

Clearer reasoning and boundaries

Extra boundaries or awkward placement

Microkernel

Core mechanisms stay privileged; selected services become isolated servers

IPC between client, core and servers

Isolation and replacement

Messaging and coordination

Modular

A monolithic core accepts loadable components through defined interfaces

Internal calls across module interfaces

Flexible extension

Loaded code may still share kernel risk

Hybrid

Mechanisms from several models are combined

Depends on service placement

Practical trade-offs

More complex design and classification

Loadable modules do not by themselves create a microkernel because a module may still execute in shared kernel space. A graphical desktop does not reveal whether its kernel is monolithic, microkernel or hybrid. Linux Kernel Architecture Explained traces x86-64 write() registers and VFS dispatch. The five-design comparison here classifies where services live and how they communicate.

Worked structure example: route one 2,000-byte write

Reuse write(5, buffer+0, 2000). Model A places the system-call handler, file service and block driver in a shared kernel. Given costs are 0.8 microseconds for the syscall boundary, 0.1 for handler to file service, and 0.1 for file service to driver. Structural routing overhead is 0.8 + 0.1 + 0.1 = 1.0 microsecond.

Model B is a microkernel-style teaching design. Its file server is in a separate address space at PID 40, and its block-driver server is at PID 52. The route has four one-way IPC messages: client to PID 40, PID 40 to PID 52, PID 52 to PID 40, and PID 40 to client. At the supplied 0.6 microseconds per message, overhead is 4 x 0.6 = 2.4 microseconds. The difference is 2.4 - 1.0 = 1.4 microseconds.

Model A has the lower routing number here. Model B separates the driver from the client and file server, so a PID 52 failure has a narrower address-space boundary and may permit a restart, although the write can fail. Neither result declares a universal winner. Both totals exclude copying, device I/O, queues and recovery time.

Routing diagrams compare Model A's 1.0-microsecond kernel path with Model B's 2.4-microsecond IPC path, including a PID 52 failure boundary.

Interface and structure traps that cause wrong answers

Tempting claim

Correction

Worked-value check

Every API call is a system call

An API call may make zero, one or many system calls

save_file(...) makes five here

A system call means a process switch

A mode change can return to the same thread

No switch cost is given

Requested count equals returned count

A real write can return fewer bytes

Full 2000 returns are assumed here

Modules mean microkernel

Modules may execute in shared kernel space

Check placement, not the name

Layers equal privilege levels

A logical layer need not be a CPU protection ring

Do not count layers as rings

Count all five unbatched calls, including open and close. Byte cost stays unchanged when only call granularity changes. The 1.0 and 2.4 microseconds values are supplied, not measured. Identify user interface, placement and communication before labelling the architecture.

How exams test OS structure and interface

Questions ask you to order the user-to-hardware path, distinguish an API from a system call and kernel service, match structure to service placement, or calculate overhead from supplied values.

Check that you can answer these four points:

  • The batched save makes 3 system calls.

  • Its simplified total is 14.4 microseconds.

  • Separate file and driver server address spaces suggest a microkernel-style design.

  • Loading a driver into shared kernel space does not alone create a microkernel.

Distractors often cross categories. A GUI is a human interface, not a kernel structure. A mode switch is not automatically a context switch. Fewer messages may improve a supplied routing number, but they prove neither better isolation nor better overall performance. Use the four checks above to test the model before moving to mixed OS questions.

The short version and next step

Remember the chain: an interface tells a caller how to ask, a system call crosses the protection boundary, and kernel structure decides where services live and communicate. The numerical anchors are 16.0 versus 14.4 microseconds for call granularity, and 1.0 versus 2.4 microseconds for the supplied structures. Exam-focused learners can continue with GATE Guidance by Sanchit Sir; learners building a wider foundation can use the Zero to Hero Complete CS Course. Redraw both diagrams, then recompute the first example with four 1,500-byte writes.