473,322 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Where to Find Linux API Information?

I'll be using gcc under Red Hat Enterprise Linux.

Where do I find information about the low-level calls to the operating
system from compiled 'C'?

For example, if I want to cause a process to sleep, or look at the
permissions of a file ... where is this written down?

Thanks, Dave.

Nov 27 '06 #1
15 2383
David T. Ashley wrote:
I'll be using gcc under Red Hat Enterprise Linux.

Where do I find information about the low-level calls to the operating
system from compiled 'C'?

For example, if I want to cause a process to sleep, or look at the
permissions of a file ... where is this written down?
This is out of topic here.

As a short answer, "Advanced programming in the Unix
environment" by Stevens and Rago is an excellent resource.

For further questions on this topic try comp.unix.programmer

Nov 27 '06 #2
"David T. Ashley" <dt*@e3ft.comwrites:
I'll be using gcc under Red Hat Enterprise Linux.

Where do I find information about the low-level calls to the operating
system from compiled 'C'?
Your question is outside the domain of comp.lang.c, which discusses
only the standard C programming language, including the standard C
library. This is a remarkably narrow topic compared to what many
people expect.

For your convenience, the list below contains topics that are not
on-topic for comp.lang.c, and suggests newsgroups for you to explore
if you have questions about these topics. Please do observe proper
netiquette before posting to any of these newsgroups. In particular,
you should read the group's charter and FAQ, if any (FAQs are
available from www.faqs.org and other sources). If those fail to
answer your question then you should browse through at least two weeks
of recent articles to make sure that your question has not already
been answered.

* OS-specific questions, such as how to clear the screen,
access the network, list the files in a directory, or read
"piped" output from a subprocess. These questions should be
directed to OS-specific newsgroups, such as
comp.os.ms-windows.programmer.misc, comp.unix.programmer, or
comp.os.linux.development.apps.

* Compiler-specific questions, such as installation issues,
locations of header files, configuring your C development
environment, or choosing or managing profiling tools,
debuggers, or code coverage tools. Ask about these in
compiler-specific newsgroups, such as gnu.gcc.help or
comp.os.ms-windows.programmer.misc. Questions about writing
compilers are appropriate in comp.compilers.

* Library-specific questions, such as how to use GLib, Kazlib,
libavl, libsndfile, GMP, GNU GSL, djbfft, CLAPACK, CBLAS,
libtomcrypt, etc. Ask about these in library-specific
newsgroups or mailing lists.

* Processor-specific questions, such as questions about
assembly and machine code. x86 questions are appropriate in
comp.lang.asm.x86, embedded system processor questions may
be appropriate in comp.arch.embedded.

* ABI-specific questions, such as how to interface assembly
code to C. These questions are both processor- and
OS-specific and should typically be asked in OS-specific
newsgroups.

* Algorithms, except questions about C implementations of
algorithms. "How do I implement algorithm X in C?" is not a
question about a C implementation of an algorithm, it is a
request for source code. Newsgroups comp.programming and
comp.theory may be appropriate.

* Making C interoperate with other languages. C has no
facilities for such interoperation. These questions should
be directed to system- or compiler-specific newsgroups. C++
has features for interoperating with C, so consider
comp.lang.c++ for such questions.

* The C standard, as opposed to standard C. Questions about
the C standard are best asked in comp.std.c.

* C++. Please do not post or cross-post questions about C++
to comp.lang.c. Ask C++ questions in C++ newsgroups, such
as comp.lang.c++ or comp.lang.c++.moderated.

* Test posts. Please test in a newsgroup meant for testing,
such as alt.test.

news.groups.questions is a good place to ask about the appropriate
newsgroup for a given topic.

--
"I don't have C&V for that handy, but I've got Dan Pop."
--E. Gibbons
Nov 27 '06 #3
On Mon, 27 Nov 2006 19:04:42 -0500, David T. Ashley wrote:
Where do I find information about the low-level calls to the operating
system from compiled 'C'?
The system calls are documented in section 2 of the online manual. If you
know the name of the system call, you can see it by using this
command:

$ man 2 name

where 'name' is replaced by the system call name. For example,

$ man 2 read

for the read(2) system call. Notice the practice of using the manual
section number (2) to disambiguate from the C runtime library's
read(3) routine. (Library routines go into section 3 of the manual).

To see all available system calls, you can do this:

$ cd /usr/share/man/man2
$ for x in *gz
do
zcat $x | nroff -man | less
done

and reading, and reading, and reading...
Nov 27 '06 #4
Tommy Reynolds <To************@MegaCoder.comwrites:
On Mon, 27 Nov 2006 19:04:42 -0500, David T. Ashley wrote:
>Where do I find information about the low-level calls to the operating
system from compiled 'C'?

The system calls are documented in section 2 of the online manual.
[snip]

The distinction between system calls and calls to library functions is
usually irrelevant, for reasons that are best discussed in a newsgroup
other than comp.lang.c.

This is cross-posted to alt.os.linux; I've redirected followups there.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 28 '06 #5
ray
On Mon, 27 Nov 2006 18:12:37 -0600, Tommy Reynolds wrote:
On Mon, 27 Nov 2006 19:04:42 -0500, David T. Ashley wrote:
>Where do I find information about the low-level calls to the operating
system from compiled 'C'?

The system calls are documented in section 2 of the online manual. If you
know the name of the system call, you can see it by using this
command:

$ man 2 name

where 'name' is replaced by the system call name. For example,

$ man 2 read

for the read(2) system call. Notice the practice of using the manual
section number (2) to disambiguate from the C runtime library's
read(3) routine. (Library routines go into section 3 of the manual).

To see all available system calls, you can do this:

$ cd /usr/share/man/man2
$ for x in *gz
do
zcat $x | nroff -man | less
done

and reading, and reading, and reading...
Much simpler to use xman.

Nov 28 '06 #6
"David T. Ashley" wrote:
>
I'll be using gcc under Red Hat Enterprise Linux.

Where do I find information about the low-level calls to the
operating system from compiled 'C'?

For example, if I want to cause a process to sleep, or look at
the permissions of a file ... where is this written down?
In the documentation for your system. Nothing to do with C.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 28 '06 #7
"CBFalconer" <cb********@yahoo.comwrote in message
news:45***************@yahoo.com...
>
>For example, if I want to cause a process to sleep, or look at
the permissions of a file ... where is this written down?

In the documentation for your system. Nothing to do with C.
Yes and no. I've never figured out the exact relationship between the C
library and the underlying system calls. I figured this would be a good
place to start with the questions.

For example, "man 3 sleep" gives:

sleep() may be implemented using SIGALRM; mixing calls to alarm() and
sleep() is a bad idea.

I'm not really sure what is going on under the hood there, or why the word
"may" was chosen.

And you cited "documentation for your system". That is what ... I'm trying
to find.

Nov 28 '06 #8
"David T. Ashley" <dt*@e3ft.comwrites:
"CBFalconer" <cb********@yahoo.comwrote in message
news:45***************@yahoo.com...
>>
>>For example, if I want to cause a process to sleep, or look at
the permissions of a file ... where is this written down?

In the documentation for your system. Nothing to do with C.

Yes and no. I've never figured out the exact relationship between the C
library and the underlying system calls. I figured this would be a good
place to start with the questions.

For example, "man 3 sleep" gives:

sleep() may be implemented using SIGALRM; mixing calls to alarm() and
sleep() is a bad idea.

I'm not really sure what is going on under the hood there, or why the word
"may" was chosen.

And you cited "documentation for your system". That is what ... I'm trying
to find.
What we discuss here is the standard C programming language, as
defined by the ISO standard (either the 1990 or 1999 version). If
you're sufficiently interested, the latest draft of the standard is
n1124.pdf; it's not light reading, but it's a good way to find out
what's defined by the standard and what isn't.

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.cis a good
introduction to the newsgroup, but I can't reach the site at the
moment.

The C standard makes no distinction between library calls and system
calls. sleep() and alarm() in particular are not standard C
functions. For more information, comp.unix.programmer or one of the
Linux groups is a better place to ask than this is.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 28 '06 #9
On 2006-11-28, David T. Ashley <dt*@e3ft.comwrote:
I'll be using gcc under Red Hat Enterprise Linux.

Where do I find information about the low-level calls to the operating
system from compiled 'C'?

For example, if I want to cause a process to sleep, or look at the
permissions of a file ... where is this written down?
Get the glibc-doc package for whatever distro you're using and you
should find most of the stuff in there.

So, if you're running Debian, Ubuntu, Knoppix or something with apt,
type

apt-get install glibc-doc

and after the installation the files should be in
/usr/share/doc/glibc-doc.

Also, I reccomend for you to get ahold of "Art of Unix programming"
(Eric Steven Raymond) and especially "Advanced Linux programming"
(Mitchell-Oldham-Samuel).

--
Uspjesne regije, tvrtke, muskarci i zene znaju da je uvijek bolje biti
prvorazredna verzija sebe nego drugorazredna verzija nekog drugog.
Nov 28 '06 #10
On 2006-11-28 01:04, David T. Ashley wrote:
I'll be using gcc under Red Hat Enterprise Linux.

Where do I find information about the low-level calls to the operating
system from compiled 'C'?

For example, if I want to cause a process to sleep, or look at the
permissions of a file ... where is this written down?

Thanks, Dave.
The manuals are in different sections:

man man
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conven-
tions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]

If you do:
apropos sleep , you will see available manuals in different sections.

sleep (3) - Sleep for the specified number of seconds
clock_nanosleep (3p) - high resolution sleep with specifiable clock (ADVANCED
REALTIME)
sleep (1) - delay for a specified amount of time
ata_busy_sleep (9) - sleep until BSY clears, or timeout
sleep (3p) - suspend execution for an interval of time
Usleep (1) [usleep] - sleep for the specified number of microseconds
Time::HiRes (3pm) - High resolution alarm, sleep, gettimeofday, interval timers
nanosleep (2) - pause execution for a specified time
usleep (3p) - suspend execution for an interval
Tcl_Sleep (3) - delay execution for a given number of milliseconds
nanosleep (3p) - high resolution sleep (REALTIME)
sleep (1p) - suspend execution for an interval
usleep (3) - suspend execution for microsecond intervals
msleep_interruptible (9) - sleep waiting for signals
usleep (1) - sleep for the specified number of microseconds
schedule_timeout (9) - sleep until timeout
msleep (9) - sleep safely even with waitqueue interruptions

/birre
Nov 28 '06 #11
David T. Ashley wrote:
For example, "man 3 sleep" gives:

sleep() may be implemented using SIGALRM; mixing calls to alarm() and
sleep() is a bad idea.

I'm not really sure what is going on under the hood there, or why the word
"may" was chosen.
Because different OSes may have a different way of doing timers.

You sir, need to take a comp.sci degree, in particular, study hard
during your operating systems classes.

Tom

Nov 28 '06 #12
2006-11-28 <11**********************@80g2000cwy.googlegroups. com>,
Tom St Denis wrote:
David T. Ashley wrote:
>For example, "man 3 sleep" gives:

sleep() may be implemented using SIGALRM; mixing calls to alarm() and
sleep() is a bad idea.

I'm not really sure what is going on under the hood there, or why the word
"may" was chosen.

Because different OSes may have a different way of doing timers.
Or the library may operate differently for short sleep()s vs long ones.

Or odd ones vs even ones, who knows. Short vs long at least makes some
sense.
You sir, need to take a comp.sci degree, in particular, study hard
during your operating systems classes.

Tom
Nov 28 '06 #13
"David T. Ashley" <dt*@e3ft.comwrote in message
news:Sq***********@fe75.usenetserver.com...
Yes and no. I've never figured out the exact relationship between the
C library and the underlying system calls. I figured this would be a
good place to start with the questions.

For example, "man 3 sleep" gives:

sleep() may be implemented using SIGALRM; mixing calls to alarm()
and sleep() is a bad idea.

I'm not really sure what is going on under the hood there, or why the
word "may" was chosen.

And you cited "documentation for your system". That is what ... I'm
trying to find.
<OT>
"man" _is_ the documentation for your system. The actual C and POSIX
standards may help, but your system provides a lot of things that aren't
in either.

The difference between library functions and system calls is that the
syscalls are direct access to the kernel, whereas library functions are
not _directly_ turned into system calls.

This gets confusing only because libc provies a convenient C interface
to the syscalls, i.e. the stuff in section 2 of the manual. The stuff
in section 3 of the manual either is built on top of the syscalls, e.g.
fread(3) probably calls read(2), or is handled entirely in userspace,
e.g. qsort(3) doesn't need any help from the kernel.

If you only use functions from section 3, your code has a chance of
being portable to non-POSIX systems, though there's still a lot of
(non-C-Standard) stuff in there that might not happen to exist on other
systems but you could either work around or reimplement yourself when
porting. If you stray into section 2, you'll definitely be limited to
POSIX systems or possibly even the particular OS you're on.
</OT>

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking
--
Posted via a free Usenet account from http://www.teranews.com

Nov 28 '06 #14
Random832 wrote:
Or the library may operate differently for short sleep()s vs long ones.

Or odd ones vs even ones, who knows. Short vs long at least makes some
sense.
Well one may use SIGALRM and another may have SIGTIMR, and another may
invoke a syscall, and another may ....

Different OSes pass messages in different ways. *That's* why you don't
mix alarm with sleep, because you don't know if your platform uses it
(which is valid).

Tom

Nov 28 '06 #15

David T. Ashley wrote:
I'll be using gcc under Red Hat Enterprise Linux.

Where do I find information about the low-level calls to the operating
system from compiled 'C'?

For example, if I want to cause a process to sleep, or look at the
permissions of a file ... where is this written down?

Thanks, Dave.
i guess this might help..
http://www.cs.cf.ac.uk/Dave/C/

Nov 29 '06 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dean Arpajian | last post by:
Looking to find info/ libs on creating (small) video files. Basically what I'm looking for is a tutorial for constructing a short video... (nothing nasty: output from a transmission line...
1
by: srihari | last post by:
Hai, I am trying to install IBM DB2 8.1 on Red Hat linux 8.0. My machine is Intel XEON 64bit. The installation went well except for the creation of tools catalog. When I tried to install the tools...
4
by: Tom Walker | last post by:
I cannot get the WHERE statement to work correctly unless I use a literal with the LIKE. I want to use a working storage data name so that I can vary the WHERE statement. Example that works: ...
1
by: sbxjld | last post by:
Hi, I would like to get information about the db2 paramater READLIMIT, that was introduced in V7R1. I cannot find the location of a IBM manula describing the option : who can help me ? Thanks...
13
by: Viken Karaguesian | last post by:
Hello everyone, Can anyone recommend a good online site to learn PHP? The W3Schools website is quite lacking - leaves much to be desired. I'm sure there are many places, but which ones are good?...
17
by: John Salerno | last post by:
Ok, I've been browsing through the MySQLdb docs, and I *think* I know the kind of code I need to write (connect, cursor, manipulate data, commmit, etc. -- although I probably need to get more...
17
by: David T. Ashley | last post by:
Hi, On a Linux platform, I have the need to call a compiled 'C' program from a PHP script (to do some special authentication), and to keep the information passed from the PHP script to the...
2
by: vilebuzz | last post by:
I sell on ebay alot and I'm starting to search online to find other options to sell computers. What I mainly do is buy used desktops and upgrade them w/ better/newer parts for resale. But do to...
2
by: lajam | last post by:
Hello, I'm trying to assign data into an array with the nonzero function. There is my code. from numarray import * diff_temp=(logical_and(values -2,values < 2)).nonzero() This command...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.