The O/S provides these services through a Systems Programming API (Application Programmers Interface). Each O/S supplies such an API.
The API will usually be in the language the O/S is written in. MSDOS is written in 8086 Assembler, so the O/S API defines an assembly level interface: load registers and call an interrupt. Unix is written in C, and supplies a C function library. The Java O/S is written in Java and supplies a set of Java classes
There may be other APIs for other languages, which call into the base API set. For example, there is a C library for MSDOS, which just supplies a library of C functions that load registers, call an interrupt and return values back from registers. There is an Ada API for Unix, where Ada procedures call the C API.
At link time, the systems functions must be resolved like any other functions of the program are. This may involve linking in other sets of libraries, and may need link parameters to do this.
Every system call must include an error reporting mechanism. For C, this may be via the function return value. For C++, Ada, Eiffel, Java an exception can be raised, or return values used. Global error variables, or special registers may be set. ``Illegal values'' may be set to indicate errors.