LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 11-12-2007, 04:48 AM   #1
ravi.srivastava
LQ Newbie
 
Registered: May 2007
Posts: 3

Rep: Reputation: 0
Red face Linux Thread Creation Problem


Hi,

I am using Linux 2.4 kernel. I am intended to create 1024 threads in a loop after each seconds. The program continues and creates upto creation of 305 threads and exits. The return code of pthread_create() is 12 after when creating 306th thread. I used perror() , it writes "Cannot Allocate Memory". I am running the program as root user.

can any person help me to create 1024 such threads??

Ravi
 
Old 11-12-2007, 05:50 AM   #2
somethingfoo
LQ Newbie
 
Registered: May 2006
Posts: 8

Rep: Reputation: 0
I assume that you have checked so that you actually do NOT run out of memory (as implied by the error message)?
 
Old 11-12-2007, 07:31 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
are you mad?
 
Old 11-12-2007, 06:55 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
BB, I was going to ask the OP 'Why???', but your post made me laugh....
 
Old 11-13-2007, 02:55 AM   #5
somethingfoo
LQ Newbie
 
Registered: May 2006
Posts: 8

Rep: Reputation: 0
Quote:
Originally Posted by bigearsbilly View Post
are you mad?
Hehe.. Kinda what I meant, but I think that I wrapped it up nicer

..anyways - 1024 threads is quite a few threads and depending on what kind of memory requirements you have in each thread, the creation of such a vast amount of threads might (will) not be feasible.

Might I ask why you need such a huge amount of threads anyways? There might be a much better way to solve your problem, rather than spewing out threads.
 
Old 11-13-2007, 01:58 PM   #6
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
I'm inclined to believe that BB got it exactly right. Sometimes you have to hit the tin to make your point. Blunt but very much to the point.

PAix
 
Old 11-14-2007, 02:22 AM   #7
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
well, it was meant mostly in fun, so I hope the OP was not offended.
 
  


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
Maximum Thread creation in solaris nav_123 Solaris / OpenSolaris 3 02-21-2007 02:14 AM
Thread Creation failing arunka Programming 1 07-18-2006 03:27 PM
Problem about process vs. thread in Linux scanner Linux - Newbie 7 07-09-2006 11:46 PM
code creation problem echo_max Linux - Software 2 09-03-2005 02:16 AM


All times are GMT -5. The time now is 03:42 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration