LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   process ,threads and system calls (https://www.linuxquestions.org/questions/linux-newbie-8/process-threads-and-system-calls-655339/)

raedbenz 07-12-2008 02:27 PM

process ,threads and system calls
 
Hi,
i am newbit to Linux. i have been reading many books and tutorials online about kernel and etc....
i feel like still i need a solid and simple example, that shows the difference among the three terms (process ,threads and system calls).
if we assume this "hello world" code:
Code:

#include <stdio.h>

int main(void)
{
        printf("Hello World");
       
        return 0;
}

In the above code which is the process? which is the thread and which the system call?
if u have a better example plz post it.
thanks

AceofSpades19 07-12-2008 02:47 PM

when you run that program it is a process and it is a new thread(AFAIK)
this sounds suspiciously like homework

raedbenz 07-12-2008 02:52 PM

Quote:

Originally Posted by AceofSpades19 (Post 3212438)
when you run that program it is a process and it is a new thread(AFAIK)
this sounds suspiciously like homework

lol, actually its not homewrok,
where is the system call in here?
any better examples?
more over POSIX or ANSI C functions (like sigaction(),setitimer(),mmap() etc...)are considered threads or what?

thanks

AceofSpades19 07-12-2008 03:01 PM

Quote:

Originally Posted by raedbenz (Post 3212441)
lol, actually its not homewrok,
where is the system call in here?
any better examples?
more over POSIX or ANSI C functions (like sigaction(),setitimer(),mmap() etc...)are considered threads or what?

thanks

Code:

#include <stdio.h>


int main(void){
system("echo hello");
return 0;
}

that makes a system call
a function call does not normally make a new thread

raedbenz 07-12-2008 03:09 PM

Quote:

Originally Posted by AceofSpades19 (Post 3212438)
and it is a new thread(AFAIK)
k

well some processes have more than thread ,isn't it?
like what?

AceofSpades19 07-12-2008 03:57 PM

Quote:

Originally Posted by raedbenz (Post 3212462)
well some processes have more than thread ,isn't it?
like what?

yes, a process can have more then one thread. Here are some links about threading
http://www.ibm.com/developerworks/library/l-posix1.html
http://arstechnica.com/articles/paed...rthreading.ars

raedbenz 07-12-2008 04:01 PM

HI,
sigaction() is system call or API?
setitimer() is system call or API?

thanks

AceofSpades19 07-12-2008 04:29 PM

Quote:

Originally Posted by raedbenz (Post 3212512)
HI,
sigaction() is system call or API?
setitimer() is system call or API?

thanks

if you google those, I'm sure the results will tell you what they are ;)

raedbenz 07-12-2008 04:31 PM

lol,
if i had not googled, then i would post a thread from the begging.
But bcoz i have some misconceptions thats y i posted this thread.
Unless u dont know the answer ;)

AceofSpades19 07-12-2008 04:59 PM

sigaction() is part of the c library and setitimer() is a system call

chrism01 07-14-2008 02:56 AM

and, incidentally, system() is in fact a library call, not a system call ;)

raedbenz 07-14-2008 03:06 AM

HI chrism,

AceofSpace19 said
Quote:

Code:

#include <stdio.h>
int main(void){
system("echo hello");
return 0;
}

that creates a system call
Quote:

Originally Posted by chrism01 (Post 3213615)
and, incidentally, system() is in fact a library call, not a system call ;)

How ?

AceofSpades19 07-14-2008 03:24 AM

Quote:

Originally Posted by chrism01 (Post 3213615)
and, incidentally, system() is in fact a library call, not a system call ;)

really?, I read that it was a system call

fbianconi 07-14-2008 05:10 AM

http://www.cs.cf.ac.uk/Dave/C/ this is a good book you can get started with.
Is from University of Leeds, and has an ugly copyright, but still readable online.
here can found more:
http://en.wikibooks.org/wiki/Programming:C
sorry can't edit links on ephy :(

smoked kipper 07-14-2008 08:16 AM

Code:

man man
System calls are documented in section 2, C libaray function in section 3.

Quote:

MANUAL SECTIONS
The standard sections of the manual include:

1 User Commands
2 System Calls
3 C Library Functions
4 Devices and Special Files
5 File Formats and Conventions
6 Games et. Al.
7 Miscellanea
8 System Administration tools and Deamons


All times are GMT -5. The time now is 11:22 PM.