01-26-2008
This changes from kernel to kernel and you really should read a kernel book for the version of the os that you're interested in. But a few general comments... a few system calls may not be system calls. An example is getpid(), it may be possible for a process to obtain it's own pid without involving the kernel. The real system calls have C wrappers... there really is a write() function in the library for you to call. In a typical implementation, it will call a syscall() function with a first parameter which is the system call number. (But depending on the system call, it may need to do some work first.) These system call numbers are usually in a file called /usr/include/sys/syscall.h and that is how you can see the real system calls. syscall() is always written in assembler and it will usually invoke an instruction that behaves a lot like a hardware interrupt. It calls a kernel routine much like a disk interrupt would invoke a disk driver. The kernel, including drivers and the kernel's system call routine, operate in a higher mode than user code and the kernel has access to instructions that a user program cannot run. These almost always include instruction to read or write data from an alternate address space. The kernel would use this to read the buffer during a write(). But there isn't any need to put data in the user buffer during a write. When the system call in the kernel is finished, it invokes a special return instruction that goes back to the syscall() routine in user space. syscall() has a way to obtain a few integers from the kernel, usually because the kernel stored them in registers. This includes the return code, and errno. The syscall() routines stores these integers in a common place and returns the write() (or whatever) wrapper that the user called. The wrapper may have some work to do depending on the system call. Then it returns to the caller.
This is very general description, and again, you should read an internals book specific to your version of unix for more details.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
What does the system call "dup" do?
What is the difference between dup and dup2
I have a fair idea of what it does but I am confused when its coming down to the exact details...
Please help me!:confused: (2 Replies)
Discussion started by: clickonline1
2 Replies
2. UNIX for Dummies Questions & Answers
Which system calls are made for operations cp and mv (2 Replies)
Discussion started by: gaurava99
2 Replies
3. UNIX for Dummies Questions & Answers
open, creat, read, write, lseek and close
Are they all primitive?
:confused:
*Another Question: is there a different between a system call, and an i/o system call? (2 Replies)
Discussion started by: PlunderBunny
2 Replies
4. Solaris
where can i find the differences in System calls between solaris and aix?
also is it possible to find a comprehensive list of them? (1 Reply)
Discussion started by: TECHRAMESH
1 Replies
5. UNIX Desktop Questions & Answers
Hi,
I'm new to UNIX system calls. Can someone share your knowledge as to how exactly system calls should be executed?
Can they be typed like commands such as mkdir on the terminal itself? Also, are there any websites which will show me an example of the output to expect when a system call like... (1 Reply)
Discussion started by: ilavenil
1 Replies
6. Programming
why user is not able to switch from user to kernel mode by writing the function whose code is identical to system call. (1 Reply)
Discussion started by: joshighanshyam
1 Replies
7. BSD
what is the functions and relationship between fork,exec,wait system calls
as i am a beginer just want the fundamentals. (1 Reply)
Discussion started by: sangramdas
1 Replies
8. UNIX for Dummies Questions & Answers
Hi all,
I am new here .
I want to know about system call in detail.
As system calls are also function .How system identifies it.:) (2 Replies)
Discussion started by: vishwasrao
2 Replies
9. UNIX for Dummies Questions & Answers
Hello,
how would i be able to call ps in C programming?
thanks,
---------- Post updated at 01:39 AM ---------- Previous update was at 01:31 AM ----------
here's the complete system call, ps -o pid -p %d, getpit() (2 Replies)
Discussion started by: l flipboi l
2 Replies
10. UNIX for Dummies Questions & Answers
I have scheduled couple of shell scripts to run using 'at' command.
The o/p of at -l is:
$ at -l
1320904800.a Thu Nov 10 01:00:00 2011
1320894000.a Wed Nov 9 22:00:00 2011
1320876000.a Wed Nov 9 17:00:00 2011
$ uname -a
SunOS dc2prcrptetl2 5.9 Generic_122300-54 sun4u sparc... (2 Replies)
Discussion started by: superparticle
2 Replies
LEARN ABOUT MINIX
syscall
syscall(3UCB) SunOS/BSD Compatibility Library Functions syscall(3UCB)
NAME
syscall - indirect system call
SYNOPSIS
/usr/ucb/cc [ flag ... ] file ...
#include <sys/syscall.h>
int syscall(number, arg, ...);
DESCRIPTION
syscall() performs the function whose assembly language interface has the specified number, and arguments arg .... Symbolic constants for
functions can be found in the header <sys/syscall.h>.
RETURN VALUES
On error syscall() returns -1 and sets the external variable errno (see intro(2)).
FILES
<sys/syscall.h>
SEE ALSO
intro(2), pipe(2)
NOTES
Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system
libraries or in multi-thread applications is unsupported.
WARNINGS
There is no way to use syscall() to call functions such as pipe(2) which return values that do not fit into one hardware register.
Since many system calls are implemented as library wrappers around traps to the kernel, these calls may not behave as documented when
called from syscall(), which bypasses these wrappers. For these reasons, using syscall() is not recommended.
SunOS 5.10 22 Jan 1993 syscall(3UCB)