Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!rutgers!cbmvax!ag From: ag@cbmvax.UUCP (Keith Gabryelski) Newsgroups: comp.unix.wizards Subject: Re: Indirect system call Message-ID: <8494@cbmvax.UUCP> Date: 9 Nov 89 17:03:21 GMT References: <28945@shemp.CS.UCLA.EDU> Reply-To: ag@cbmvax.UUCP (Keith Gabryelski) Organization: Commodore Technology, West Chester, PA Lines: 37 In article <28945@shemp.CS.UCLA.EDU> dieter@lynn.cs.ucla.edu (Dieter Rothmeier) writes: >While browsing through section 2 of the Unix manual, I came upon the >concept of an indirect system call, as in syscall(2). Now that >puzzled me. What might be the use for such a facility? On Unix, system calls are invoked from a user process by passing [*] a (system call) number to a routine in the kernel which uses this number to look up what routine to call in the kernel via the sysent array [**]. The sysent array is really a big structure array list of system calls, like open(), read(), signal(), and fork() that may also include the number of arguments to the function and some other useful info. There is usually some left over space at the end (or middle) of this array that can be used to place custom system calls if one disires. Then, using syscall(), you can invoke your specified routine. Once you get the hang of it and a good debugger, it is actually easy to add your own system call if you have the capability to link a new kernel. I have an example of adding select() to a 2.3 SCO Xenix system that was posted to comp.unix.xenix almost a year back. It used the technique above to add select(), sigset(), and friends. If you would like I will send it to you. Pax, Keith * Passing oneself to a kernel is sort of funky. It usually requires using some special machine langauge instruction such as TRAP or to some how cause an exception to otherwise occur (possibly jumping to a specified illegal memory location that the kernel will catch and do `special stuff' with). ** The reason for all this is that it allows one to have set entry points into the kernel that are controlled by the kernel. -- ag@cbmvax.commodore.com Keith M. Gabryelski ...!uunet!cbmvax!ag