LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-28-2003, 12:15 PM   #1
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Rep: Reputation: 30
Question Multi threading


In the name of God
Hi,
is it possible to write a program in C++ in Linux which does a couple of jobs at once, kind of something like multi tasking (or processing)?
 
Old 03-01-2003, 05:12 AM   #2
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
Yes, you can use POSIX threads for multithreading, or various classic UNIX system calls (fork() et al) to spawn new processes. Threads share memory between them; processes don't. As regards multiprocessing, if you have more than one processor, different threads/processes may be executed on different processors.

There should be plenty of information on both available through google.

Alex
 
Old 03-01-2003, 12:28 PM   #3
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Original Poster
Rep: Reputation: 30
Alex, I don't know much about threads. I thougth multithreading is multiprogramming, but it seems that I was wrong. could you describe me more about threads. What is that?

By the way, is it easy to write a code, which perform different jobs all at the same time?
 
Old 03-01-2003, 03:47 PM   #4
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
DISCLAIMER : Ignore my horrible spelling

>>By the way, is it easy to write a code, which perform different jobs all at the same time?

Who cares if it's easy or not? If you need to do it don't worry about the difficulty.

The term Multi-threading refers to simultanious (from our point of view) execution. Multi-threaded programs can be thought of as every program having at least one thread. The main thread could do something like handle an interface, while another path of execution - or thread - handles requests.

The term multiprogramming is unfamiliar to me. The alternitive to multi-threading on *NIX systems (and more often the chosen route) is that of fork()ing. man fork. Forking is different because it creates a whole other process, instead of having one process with mulitple execution paths.

Mozilla & Internet Explorer. IE makes you open a new window for each browser you want (fork()ing). Mozilla lets you have many views open in the same browser windows (threads). Sorry if it's confusing ... but I tried

I would elaborate, but I must attend a prior engagement. Good luck.
 
Old 03-01-2003, 09:09 PM   #5
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
I think, if you want to understand fully and clearly what is thread and processes, and the differences between them, you should pick up and read a book or a webpage on the "operating system" concepts. If you don't have the background knowledge, it would be quite tough to understand them.
( But if you have no time, you can just start the programming and ofcourse you might not know what exactly it is.)

Last edited by moeminhtun; 03-03-2003 at 12:00 AM.
 
Old 03-01-2003, 11:13 PM   #6
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Original Poster
Rep: Reputation: 30
OK,
I borrowed "Sams Linux programming" from our library. 1/3 of this book (about 300 pages) was the source code of Minix. Also it was too difficault for me to understand what it said (not only because of my English but the unfamiliar description it had through the book). In this book it was assumed that you already know everything about UNIX OS, and then it started to tell you exactly what it does on different layers.
Well, did anyone experimented about multithreading before. I want a simple code (or manual) to do for example 3 calculations simultaneously.
 
  


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
dlopen in multi-threading environnement yakotey Programming 2 06-30-2005 08:36 AM
Multi-threading question (for big time Pros) prakash_sinha Programming 13 07-14-2004 12:48 AM
help! perl multi-threading? eph Programming 0 05-03-2004 09:15 PM
multi-threading with signals TedMaul Programming 0 04-17-2004 07:35 PM
Multi-threading rch Programming 3 03-30-2003 10:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:33 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
Open Source Consulting | Domain Registration