Question:

C Programing Threads?

by  |  earlier

0 LIKES UnLike

I would like to know what threads are and how they are used in C . Some example code would be nice.

 Tags:

   Report

3 ANSWERS


  1. Threads are mini processes...

    The fork system call will create 2 processes

    See this...

    http://www.csl.mtu.edu/cs4411/www/NOTES/...

    or buy the CSAPP book for more info...or the advanced unix programming book....they are all good....

    A good exercise is to write a simple unix shell......


  2. Threads are execution vehicles. They run the code that you actually write. If you only have one thread, you don't really have to think about it. Having multiple threads allows two different sections of your code to be running at the same time.

    POSIX pthreads is an International standard for threads in the C language. I've given you some links below.

  3. Threads are separate execution paths within a single process. The code for each thread runs in parallel as if they were separate processes. They're commonly used when one task might get held up while another task is still capable of proceeding. For example, a server program might create a new thread when a client connects -- the new thread will handle the client's requests while the main thread waits for another client.

    The main differences between using threads and separate processes are how they communicate the load placed on the operating system. Interprocess communication typically uses signals, FIFOs, etc. handled by the operating system, whereas communication between threads is generally done through a shared section of memory.

    The POSIX threads (or "pthreads") API should be usable on any Unix-like system, and Windows has its own Win32 thread API. The links below demonstrate the basics of using threads in POSIX and Win32.
You're reading: C Programing Threads?

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.