System calls

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Banuba

System calls

Post by Banuba »

Hello,

Can anyone tellme a link about the system calls? I know system calls are an interrup number X that calls a funtion. But I want to know how to do libs with functions that call the sys-call. And i want to know the most common systems calls.

Thanks for all
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:System calls

Post by Pype.Clicker »

i think you can learn alot from the linux sources (syscall.h, or something). Building libraries atop of system calls implies that
  • [-] you should be able to access the library from any program (did you meant "shared libraries" or statically linked ones ?)
    [-] you must know what the library will offer. Usually, whatever a library do, the user program could do it without the library. Get a look at f<operation> interface of stdio.h, for instance: all it does is adding buffering and data formatting on top of the classic read/write system calls. usually, the library has additionnal internal state that makes the use of the system call less frequent and thus make the program run more efficiently.
Note that i don't really like the legacy "system call" approach, and that i'm working on an alternative approach that is fully Object-Oriented :)

The usual system calls depend on what your system is able of, but imho, you should at least have
  • [-] process control: start new programs, terminate program, etc.
    [-] user interaction : get input, parameters, and show results (may depend on whether you have TUI or GUI)
    [-] process communication : find another software component and talk to it.
Now, depending on what you have inside of your kernel, functions like file operations (read/write/open/close, etc), window management (raise, close, popup, settitle, get_draw_context ...), networking (connect, send, recv, ...) may be available to the program through system calls or through inter-program communication (for instance, if you decide to have the window manager as a separate program, like in X-window approach, it will not have it's own system call, but send commands through a socket - i.e. an IPC bytes tunnel.


btw, i dunno how windows NT handles it ... If someone has additionnal knowledge to share (Tim?)...
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:System calls

Post by df »

send message
receive message
-- Stu --
Whatever5k

Re:System calls

Post by Whatever5k »

These two system calls df just described are the only two system calls in a *Microkernel*. In a monolothic kernel, you have different system calls, also depending on the system you want to implement. For example in UNIX, you will need the essential system calls FORK, EXEC, READ, WRITE, OPEN and CLOSE.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:System calls

Post by df »

well.. what is an interrupt other than a send message?

smsg(EXEC, "/blah/my.exe");
exec()

maybe should explain the differenfce between an API and a SysCall? ;)

i wrote a tiny asm kernel, there was no send message or interrupts, just a vector table your app called directly at a fixed address.. it was all 'soft'.

you could also setup task gates instead of intterupt gates...

task gates / call gates worth looking into..
-- Stu --
Post Reply