Newsgroups: comp.os.minix
Subject: Re: C program
References: <H7l96.73870$eB2.5866586@news.infostrada.it> <9474li$dcot9$1@hades.rz.uni-sb.de> <slrn96ebiu.o6c.pino+comp_os_minix@mud.stack.nl> <94a1cc$diuu1$1@hades.rz.uni-sb.de>
Organization: Rochester Institute of Technology, Rochester, NY
From: aje9383@osfmail.isc.rit.edu (Andrew Erickson)
NNTP-Posting-Host: grace.isc.rit.edu
X-Original-NNTP-Posting-Host: grace.isc.rit.edu
Message-ID: <3a68b442@news.isc.rit.edu>
Date: 19 Jan 2001 16:40:18 -0500
X-Trace: 19 Jan 2001 16:40:18 -0500, grace.isc.rit.edu
Lines: 39
XPident: aje9383
X-Original-NNTP-Posting-Host: 129.21.4.100
XPident: Unknown
Path: news.adfa.edu.au!clarion.carno.net.au!news0.optus.net.au!news1.optus.net.au!optus!news.mel.connect.com.au!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!bloom-beacon.mit.edu!news.kodak.com!news-nysernet-16.sprintlink.net!news.sprintlink.net!news.isc.rit.edu!aje9383
Xref: news.adfa.edu.au comp.os.minix:36599

In article <94a1cc$diuu1$1@hades.rz.uni-sb.de>,
Mario Premke  <mapr0003@stud.uni-sb.de> wrote:
>Martijn van Buul <pino+comp_os_minix@dohd.org> wrote:
>
>
>>> Why is a system call, which is implemented in the kernel defined in the
>>> standard C-Library ?
>
>> Well, they have to be declared *somewhere*... 
>
>But wouldn't it be enough to have include files ?
>
>> To hide the mechanism of *how* these system calls are done[1], these are 
>> implemented using wrappers.
>
>If an OS tries to be POSIX conform the system calls as well as the LibC-Functions
>are called in a 'POSIX-defined' way, is that right ??

The prototypes and results of calling them must be conformant to POSIX
conventions, yes.  How, precisely, that is accomplished is entirely
different.

To the C compiler, a call to fork() or write() is handled just as any other
function call; it has no magic way of knowing that write() is a system call
and printf() isn't.  During linking, printf() becomes a call to the library
printf() function, and write() becomes a call to the wrapper function in the
library.  (The wrapper servers to translate the C function call into an
appropriate OS request, by (on Minix) setting up a message and trapping the
message mover.  The actual work of the system call takes place in the
priveleged OS code--MM, FS, the various tasks, INET, etc. etc.)

The headers are needed to tell the compiler (and, incidently, the
programmer) how to call the wrappers properly.

>Thanks,
>	Mario

-- 
Andrew Erickson
