944,198 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 837
  • C RSS
Oct 21st, 2009
0

system calls and high level statements

Expand Post »
Hi,
if any one has the idea of the internal system calls which gets activated by using high level statements ( like printf ,scanf or malloc and so on) please provide me the links or any related info.

i have an idea that the internal system calls depends on the OS/Compiler.

but i want a comprehensive description of all or few poupular OS system calls/ high level statements.
Similar Threads
Reputation Points: 13
Solved Threads: 3
Junior Poster
Gaiety is offline Offline
115 posts
since Sep 2009
Oct 21st, 2009
1
Re: system calls and high level statements
So you want us to Google for you
Reputation Points: 499
Solved Threads: 367
Postaholic
gerard4143 is offline Offline
2,198 posts
since Jan 2008
Oct 22nd, 2009
-7
Re: system calls and high level statements
I've used a debugger to step through some of the printf() code on MS-Windows and found that eventually it calls win32 api WriteFile(). From that experience I would imagine other functions also eventually call win32 api functions. But those are the details that are compiler-implementation specific. There is nothing in the c or c++ standards that tell compiler writers how to implement the standard functions; they are free to do it any way they want to.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Oct 22nd, 2009
0
Re: system calls and high level statements
Click to Expand / Collapse  Quote originally posted by gerard4143 ...
So you want us to Google for you

i googled for some time but dint find any use full rather related information about different OS system calls.

what i got was these below links but these are not having much related info.

<http://www.google.co.in/search?hl=en&q=system+calls+in+operating+system&meta=&aq=2&oq=system+calls+>

http://www.google.co.in/search?hl=en...meta=&aq=f&oq=

http://www.google.co.in/search?hl=en...meta=&aq=f&oq=


so i thought some one else would be having some other info.
Reputation Points: 13
Solved Threads: 3
Junior Poster
Gaiety is offline Offline
115 posts
since Sep 2009
Oct 22nd, 2009
0
Re: system calls and high level statements
I've used a debugger to step through some of the printf() code on MS-Windows and found that eventually it calls win32 api WriteFile(). From that experience I would imagine other functions also eventually call win32 api functions. But those are the details that are compiler-implementation specific. There is nothing in the c or c++ standards that tell compiler writers how to implement the standard functions; they are free to do it any way they want to.

Thanks for your response Dragon.

actually i work on linux OS and here i can find that read and write system calls are used as internal functions of scanf and printf.
( confused here on how the mapping is done between read ,write and scanf ,printf. because read/write takes file descriptors, buffers and size of data where as printf and scanf takes the variable lenght args: format strings and arguments)

similarly all the dma functions(malloc,calloc, realloc, memset,memcpy, memmove) also uses some built in system calls.
i just want to know is there any source that describes the library functions and whose corresponding system calls on different OS's.
i googled for some time but dint get any appropriate info.
Reputation Points: 13
Solved Threads: 3
Junior Poster
Gaiety is offline Offline
115 posts
since Sep 2009
Oct 22nd, 2009
1
Re: system calls and high level statements
If your looking for the source code for Linux system calls then download the kernel source code for your Linux distro and you'll find it there...The first file you want to investigate is - Entry.S - this file has all the code for the interrupt/syscall call that handles the dispatch....

Also this link may shed some light

http://asm.sourceforge.net/syscall.html#p3
Last edited by gerard4143; Oct 22nd, 2009 at 9:19 am.
Reputation Points: 499
Solved Threads: 367
Postaholic
gerard4143 is offline Offline
2,198 posts
since Jan 2008
Oct 22nd, 2009
1
Re: system calls and high level statements
Quote ...
confused here on how the mapping is done between read ,write and scanf ,printf. because read/write takes file descriptors, buffers and size of data where as printf and scanf takes the variable lenght args: format strings and arguments
It is not a direct mapping. printf() for example does a lot of work to parse the format string and the variable arguments. It also handles output formatting because write() does not do any of that. The file descriptor is usually stored in the FILE object for stdout that printf() uses along with other information needed to make the system calls.
Reputation Points: 1446
Solved Threads: 135
Practically a Master Poster
Tom Gunn is offline Offline
681 posts
since Jun 2009
Oct 22nd, 2009
-7
Re: system calls and high level statements
Click to Expand / Collapse  Quote originally posted by Gaiety ...
( confused here on how the mapping is done between read ,write and scanf ,printf. because read/write takes file descriptors, buffers and size of data where as printf and scanf takes the variable lenght args: format strings and arguments)
printf() also takes a file descriptor -- stdin, stdout, and stderr are three file descriptors always available to C/C++ console programs. printf(), scanf() etc do a lot of pre-processing before sending the strings on to the system functions. All the system functions do is read or write data -- they don't do anything else with it. Formatting the data has to be done by the calling functions.

Click to Expand / Collapse  Quote originally posted by Gaiety ...
similarly all the dma functions(malloc,calloc, realloc, memset,memcpy, memmove) also uses some built in system calls.
i just want to know is there any source that describes the library functions and whose corresponding system calls on different OS's.
There are descriptions of the system functions for each operating system, but you won't find them all in one convenient document. You will have to study each os that you are interested in.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Oct 22nd, 2009
0
Re: system calls and high level statements
Thank you All for your time

i will do some research on these according to your suggestions and get back to you soon


Thanks again.
Reputation Points: 13
Solved Threads: 3
Junior Poster
Gaiety is offline Offline
115 posts
since Sep 2009
Oct 22nd, 2009
-7
Re: system calls and high level statements
Hey man -- do a lot of research then write a book so that you can make millions of money
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Setting up C compiler
Next Thread in C Forum Timeline: clock() returning 0?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC