LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-14-2008, 04:18 AM   #1
goldeneagle1234
LQ Newbie
 
Registered: Sep 2008
Posts: 10

Rep: Reputation: 0
Post system calls


in file handling to open a file in c prog we use pen()which
is a system call in linux.....then why do we need to include
headers like fcntl.h,sys/types.h etc???

similarly is pthread_create also a system call???
 
Old 09-14-2008, 05:52 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
You still need to #include the header because for well-formed C code the compiler needs to know the prototype of the function. Headers just have function prototype, #defines, and the like ... they shouldn't actually contain code. Additionally, I believe that the system call is not actually run, but there's a thin wrapper in glibc around it. I'm not sure about that part, though, because it's been awhile since I've looked at it.

I don't think pthread_create is a syscall (at least grepping through arch/x86/kernel/syscall_table_32.S doesn't show it). In Linux each thread is treated as its own process (although it has the same PID, it has a different TID). I suspect that the pthreads library uses the clone(2) system call to do its work (there is an option for cloning with the same PID -- see the man page for more details).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how does java calls the system calls which are written in c babu198649 Linux - General 3 12-05-2011 04:40 AM
system calls arispipis Programming 2 03-19-2008 07:59 PM
LINUX System calls Jitin Programming 1 08-02-2006 09:47 PM
how do you use system calls? slinky2004 General 1 12-22-2005 10:39 PM
Some system calls Spooky Programming 1 11-24-2004 11:17 AM


All times are GMT -5. The time now is 03:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration