Can anyone give more details about the system calls?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Can anyone give more details about the system calls?
# 1  
Old 01-26-2008
Can anyone give more details about the system calls?

Hello,

Please can any one explain about the parameters to the write systemcalls??
How are they passed?? and how is the address of the user buffer is handled by the kenel??
for ex: write(fd,buf[20],count);
How does the kernel handles this user buffer address??

After write does the kernel write to user space??

Please can someone help me..

regards
Prakash
# 2  
Old 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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

at -l doesnt give details of the scheduled job. How to get the details?

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

2. UNIX for Dummies Questions & Answers

system calls in C

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

3. UNIX for Dummies Questions & Answers

About system calls.

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

4. BSD

system calls

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

5. Programming

System calls

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

6. UNIX Desktop Questions & Answers

Using system calls

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

7. Solaris

System calls ?

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

8. UNIX for Dummies Questions & Answers

System calls?

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

9. UNIX for Dummies Questions & Answers

System calls for cp and mv

Which system calls are made for operations cp and mv (2 Replies)
Discussion started by: gaurava99
2 Replies

10. UNIX for Dummies Questions & Answers

System Calls

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
Login or Register to Ask a Question