473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

error running p_threads

Hi,
So basically in my application I have a a main function that does
this...

//Global variables
pthread_t thread_id;

void* threadtest(void * arg) {
while(1) {
printf("Reached this segment\n");
}
return NULL;
}
int main(int argc, char** argv) {
....
printf("We've reached here!\n");
//Line 500

pthread_create(&thread_id,NULL,threadtest,NULL); //Line 501
....
}
So basically, when I run this code, I dont have my "Reached this
segment" line print out to console (so basically I feel the thread is
not being entered). But when I run in gdb, put a break point at line
500 in main (as shown below) and continue stepping, I reach the thread
code and get no errors....What could be the reason that I see no thread
output?? Is it even getting there? Sorry for my english...I can explain
anything more in detail if necessary...

-Ravi

Nov 19 '06 #1
5 1395
Hi,
And this is on Solaris machine

-Ravi

Ivar wrote:
Hi,
So basically in my application I have a a main function that does
this...

//Global variables
pthread_t thread_id;

void* threadtest(void * arg) {
while(1) {
printf("Reached this segment\n");
}
return NULL;
}
int main(int argc, char** argv) {
...
printf("We've reached here!\n");
//Line 500

pthread_create(&thread_id,NULL,threadtest,NULL); //Line 501
...
}
So basically, when I run this code, I dont have my "Reached this
segment" line print out to console (so basically I feel the thread is
not being entered). But when I run in gdb, put a break point at line
500 in main (as shown below) and continue stepping, I reach the thread
code and get no errors....What could be the reason that I see no thread
output?? Is it even getting there? Sorry for my english...I can explain
anything more in detail if necessary...

-Ravi
Nov 20 '06 #2

I guess the problem is that sub-thread end with the main thread ends,
maybe you can add one line in the main function:

int main(int argc, char** argv) {
printf("We've reached here!\n");
pthread_create(&thread_id,NULL,threadtest,NULL);
while(1);
}

On 11ÔÂ20ÈÕ, ÉÏÎç7ʱ29·Ö, "Ivar" <ravi.sath...@gmail.comwrote:
Hi,
So basically in my application I have a a main function that does
this...

//Global variables
pthread_t thread_id;

void* threadtest(void * arg) {
while(1) {
printf("Reached this segment\n");
}
return NULL;

}int main(int argc, char** argv) {
...
printf("We've reached here!\n");
//Line 500

pthread_create(&thread_id,NULL,threadtest,NULL); //Line 501
...

}So basically, when I run this code, I dont have my "Reached this
segment" line print out to console (so basically I feel the thread is
not being entered). But when I run in gdb, put a break point at line
500 in main (as shown below) and continue stepping, I reach the thread
code and get no errors....What could be the reason that I see no thread
output?? Is it even getting there? Sorry for my english...I can explain
anything more in detail if necessary...

-Ravi
Nov 20 '06 #3
co*********@gmail.com wrote:

Please don't top post.
On 11ÔÂ20ÈÕ, ÉÏÎç7ʱ29·Ö, "Ivar" <ravi.sath...@gmail.comwrote:
>>
}So basically, when I run this code, I dont have my "Reached this
segment" line print out to console (so basically I feel the thread is
not being entered). But when I run in gdb, put a break point at line
500 in main (as shown below) and continue stepping, I reach the thread
code and get no errors....What could be the reason that I see no thread
output?? Is it even getting there? Sorry for my english...I can explain
anything more in detail if necessary...
I guess the problem is that sub-thread end with the main thread ends,
maybe you can add one line in the main function:

int main(int argc, char** argv) {
printf("We've reached here!\n");
pthread_create(&thread_id,NULL,threadtest,NULL);
while(1);
}
While the cause is correctly identified, the off topic advice is unwise.

Look up pthread_join() to replace the while.

This question should have been posted to comp.programming.threads.

--
Ian Collins.
Nov 20 '06 #4

co*********@gmail.com wrote:
I guess the problem is that sub-thread end with the main thread ends,
maybe you can add one line in the main function:

int main(int argc, char** argv) {
printf("We've reached here!\n");
pthread_create(&thread_id,NULL,threadtest,NULL);
while(1);
}

On 11ÔÂ20ÈÕ, ÉÏÎç7ʱ29·Ö, "Ivar" <ravi.sath...@gmail.comwrote:
Hi,
So basically in my application I have a a main function that does
this...

//Global variables
pthread_t thread_id;

void* threadtest(void * arg) {
while(1) {
printf("Reached this segment\n");
}
return NULL;

}int main(int argc, char** argv) {
...
printf("We've reached here!\n");
//Line 500

pthread_create(&thread_id,NULL,threadtest,NULL); //Line 501
...

}So basically, when I run this code, I dont have my "Reached this
segment" line print out to console (so basically I feel the thread is
not being entered). But when I run in gdb, put a break point at line
500 in main (as shown below) and continue stepping, I reach the thread
code and get no errors....What could be the reason that I see no thread
output?? Is it even getting there? Sorry for my english...I can explain
anything more in detail if necessary...

-Ravi
Sorry about this, but I actually have a while(1) loop doing other
things in the main function....so the thread wouldn't end before the
main functiojn
Ravi

Nov 20 '06 #5
Ivar wrote:
>
Sorry about this, but I actually have a while(1) loop doing other
things in the main function....so the thread wouldn't end before the
main functiojn
Try posting to comp.programming.threads.

--
Ian Collins.
Nov 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Patrice FRITSCH | last post by:
I'm trying to run a batch file from an asp page using WScript.Shell object. Dim oWSH set oWSH= Server.CreateObject("WScript.Shell") call oWSH.Run("cmd.exe /c " & szCmd , 0, true) szCmd...
5
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
1
by: whitehorse | last post by:
When the warehousecontroller service is invoked, the following error message is sent to the application log: Event Type: Error Event Source: TFS Warehouse Event Category: None Event ID: 3000...
1
by: Spam Catcher | last post by:
Hi all, I'm moving a ClickOnce install to a development server, and I've updated my .application file with the new paths using mageui.exe. ..NET 2.0 installs OK, but right after it installs I...
0
by: silviu | last post by:
Hello I'm trying to install Microsoft SQL 2005 Server Express Edition but I'm getting the following error: SQL Server Setup unexpectedly failed... Then it says something about a log file. Here's...
7
by: Norman Diamond | last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet Framework 2. Options are set in the setup project properties, so if these two dependencies are not already installed then...
0
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi all! I am having problems on installing .NET Framework 3.5 on some machines. In one machine the error is: WinVerifyTrust returned -2146762751 Wintrust not on machine Error: O arquivo...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.