• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

Threads

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
kuist
Asked:
kuist
1 Solution
 
akshayxxCommented:
start with this ..
http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html

and try ur examples and let us know if u get stuck
0
 
kuistAuthor Commented:
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
 
akshayxxCommented:
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
Independent Software Vendors: 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!

 
kuistAuthor Commented:
humm.. sorry.. didn't see you post before I post mine..

I'll take a look at it shortly :)
0
 
KocilCommented:
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
 
bkrahmerCommented:
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
 
akshayxxCommented:
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

Technology Partners: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now