?
Solved

Threads

Posted on 2003-03-31
7
Medium Priority
?
270 Views
Last Modified: 2010-04-15
Hello!

I need some book about Threads in C for linux... I'm confortable with threads as I coded with them on other language (Java, .NET) .. but I now have to work on linux coding in C and I need multi-threads ..

any suggestion for some books about threads??


if you have some good site, feel free to post them, but I will reward someone who actually tell me a book.

Thanks
0
Comment
Question by:kuist
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 8

Accepted Solution

by:
akshayxx earned 300 total points
ID: 8243120
start with this ..
http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html

and try ur examples and let us know if u get stuck
0
 

Author Comment

by:kuist
ID: 8243122
I've just been told the only way to do multithreading under linux is to use the fork() function.

if this is correct, I'd then want some USEFUL tutorial about using this and how to synchronize threads with this method.

Thanks again :)
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8243133
this link i found on sun site
http://www.sun.com/books/catalog/lewis2/

another good name
http://www.oreilly.com/catalog/pthread/

u can find many such books .. get hold of any .. but  online examples and tutorials are good enough
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kuist
ID: 8243136
humm.. sorry.. didn't see you post before I post mine..

I'll take a look at it shortly :)
0
 
LVL 5

Expert Comment

by:Kocil
ID: 8243384
fork() is the way to Multitasking on Linux.
pthread is the way to do multithreading on Linux.

The difference :
Multitasking -> you make 2 different process, with separate data space and separate main thread. Thread of the process 1 can't alter anything at process 2 and vice versa. The process can only communicate each other by using pipe, signal or socket.

Multithreading -> you make 2 threads, but on the same process and the same data space. Both threads can alter the same data, and may communicate each other by using global memory, guarded by semaphore.

This is the complete reference:
http://www.gnu.org/manual/glibc-2.0.6/html_chapter/libc_toc.html

About fork: http://www.gnu.org/manual/glibc-2.0.6/html_chapter/libc_23.html#SEC407

About pthread: akshayxx have told it all.

 
0
 
LVL 2

Expert Comment

by:bkrahmer
ID: 8243832
I haven't worked with threads on linux yet.  However, I understand that threads appear as processes on linux.  They have process ids, show up in the process table, etc.  Is this just an artifact, or are threads on linux actually implemented via processes?

brian
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8250420
bkrahmer:
as per my understanding, On linux threads are like lightweight processes ,in the sense that they carry some properties of processes, like as u mentioned having process id and show up in process table etc.

but they certainly are different from normal processes,
threads of same process can share the program resources and u need to utilize synchronzation methods,
while u have to explicitly use IPC methods to communicate between two different processes.

i guess u knew this already.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question