C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 28th, 2010, 11:21 PM
bonjovi4u bonjovi4u is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2010
Posts: 9 bonjovi4u New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 10 m 58 sec
Reputation Power: 0
Threads in c language!!

can any one help me out in creating thread in c language??

Reply With Quote
  #2  
Old May 28th, 2010, 11:48 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,134 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 20 h 49 m 18 sec
Reputation Power: 1974
Threads are not supported by the C standard. Support for threads is platform-dependent; some operating systems support them and some don't. Many compilers provide libraries for accessing operating system support for threads, but some don't.

In order to even begin to answer your question, we must know what operating system you are using. And what compiler. For example, Turbo C 2 offers absolutely no threading support, since it's a 16-bit DOS compiler; MS-DOS did not support threading.

Reply With Quote
  #3  
Old May 29th, 2010, 12:07 AM
bonjovi4u bonjovi4u is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2010
Posts: 9 bonjovi4u New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 10 m 58 sec
Reputation Power: 0
i am using gcc and the opreating system is Redhat!

Reply With Quote
  #4  
Old May 29th, 2010, 12:47 AM
gimp's Avatar
gimp gimp is offline
<?PHP user_title("gimp"); ?>
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jan 2005
Location: Internet
Posts: 7,652 gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)gimp User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 2540 Folding Title: Novice Folder
Time spent in forums: 3 Months 6 Days 1 h 35 m 4 sec
Reputation Power: 6083
Send a message via AIM to gimp
If you're looking for third-party libraries, I recommend boost threads.
__________________
Chat Server Project & Tutorial | WiFi-remote-control sailboat (building) | Joke Thread
“Rational thinkers deplore the excesses of democracy; it abuses the individual and elevates the mob. The death of Socrates was its finest fruit.”
Use XXX in a comment to flag something that is bogus but works. Use FIXME to flag something that is bogus and broken. Use TODO to leave yourself reminders. Calling a program finished before all these points are checked off is lazy.
-Partial Credit: Sun

If I ask you to redescribe your problem, it's because when you describe issues in detail, you often get a *click* and you suddenly know the solutions.
Ches Koblents

Reply With Quote
  #5  
Old May 29th, 2010, 01:48 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,134 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 20 h 49 m 18 sec
Reputation Power: 1974
pthreads, then. It's been a long time since I've played with it, but Google should yield plenty of hits.

Reply With Quote
  #6  
Old May 29th, 2010, 02:12 AM
bonjovi4u bonjovi4u is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2010
Posts: 9 bonjovi4u New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 10 m 58 sec
Reputation Power: 0
any one has sample code here for implementing thread in c??
Comments on this post
salem disagrees: Lazy - there are no end of tutorials on the web containing your average "hello world" as a thread
programs to read - so go read some!

Reply With Quote
  #7  
Old May 29th, 2010, 10:44 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,134 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 20 h 49 m 18 sec
Reputation Power: 1974
Quote:
Originally Posted by bonjovi4u
any one has sample code here for implementing thread in c??


The problem with using Google to find something is that you need to know what it's called. You need to know that both for setting the search words and for recognizing which hits would be useful.

I gave you that. Now you can Google for information on pthreads and for sample code. Now go Google.

Reply With Quote
  #8  
Old May 31st, 2010, 12:05 AM
bonjovi4u bonjovi4u is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2010
Posts: 9 bonjovi4u New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 10 m 58 sec
Reputation Power: 0
Quote:
Originally Posted by dwise1_aol
The problem with using Google to find something is that you need to know what it's called. You need to know that both for setting the search words and for recognizing which hits would be useful.

I gave you that. Now you can Google for information on pthreads and for sample code. Now go Google.
i have gone through google enough found sevral pthread examples but every time i am compiling the code i get the following error...

/tmp/ccSzMvuS.o: In function `main':
thread.c.text+0x80): undefined reference to `pthread_create'
collect2: ld returned 1 exit status

or this



/tmp/ccmrzvzA.o: In function `main':
thread.c.text+0x3d): undefined reference to `pthread_create'
thread.c.text+0x62): undefined reference to `pthread_create'
thread.c.text+0x78): undefined reference to `pthread_join'
thread.c.text+0x8b): undefined reference to `pthread_join'
collect2: ld returned 1 exit status

Reply With Quote
  #9  
Old May 31st, 2010, 12:23 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,387 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 21 h 39 m 3 sec
Reputation Power: 4080
That means it can't find your thread library. Stick a -lthread at the end of your gcc command line.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Reply With Quote
  #10  
Old May 31st, 2010, 12:56 AM
bonjovi4u bonjovi4u is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2010
Posts: 9 bonjovi4u New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 10 m 58 sec
Reputation Power: 0
Quote:
Originally Posted by Scorpions4ever
That means it can't find your thread library. Stick a -lthread at the end of your gcc command line.
ok no the problem is solve a bit!!!

but the code wat m trying to write is not satisfiying me following is the code!!




#include <pthread.h>
#include <stdio.h>

void *PrintHello(void *threadid)
{
printf("Hello World!\n");
}

void start()
{
pthread_t threads[1];
int rc;
long t;
rc = pthread_create(&threads[1], NULL, PrintHello, (void *)1);

if (rc){
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}

pthread_exit(NULL);
}
int main (int argc, char *argv[])
{
start();
printf("Thread Still Running");
}

Reply With Quote
  #11  
Old May 31st, 2010, 04:47 AM
bonjovi4u bonjovi4u is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2010
Posts: 9 bonjovi4u New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 1 h 10 m 58 sec
Reputation Power: 0
can any one help me with this code!!!!



#include <pthread.h>
#include <stdio.h>

void *PrintHello(void *threadid)
{
while(1)
{
}
}

void start()
{
pthread_t mythread;
rc = pthread_create(&mythread, NULL, PrintHello, NULL);

}

int main (int argc, char *argv[])
{
start();
printf("Thread Still Running\n");
}

Reply With Quote
  #12  
Old May 31st, 2010, 11:10 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,387 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 21 h 39 m 3 sec
Reputation Power: 4080
1. Please read the sticky threads and post within [code] and [/code] tags. You're not a newbie here anymore.

2. What exactly is the problem you're having? All I see is some code pasted and no clue as to what problem you're having.

Reply With Quote
  #13  
Old November 15th, 2012, 01:01 AM
cmark cmark is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 cmark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 52 sec
Reputation Power: 0
Talking How to implement coding in c program to open a URL

New Friends at Dev Shed Forums:

I am very new to c language.

Going through my first class in the topic.

I have built a program that counts down from 10 to 0 at 1 second intervals and at the end I want to open a URL that will display a rocket launch in a web browser.

I am using a Pelles IDE compiler. Have not been able to find simple commands from the internet that this compiler or this program would accept to open URL. Any idea on how can get to work to open a URL? :

Here is my code so far (I just need to implement the portion of coding that would open a URL):

#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main(void)

{

int x;


for (x = 10; x >= 0; --x)


{

printf("%d\n", x);
if(x <= 10);


{
_sleep(1);
}




}


return(0);

}

Reply With Quote
  #14  
Old November 15th, 2012, 11:07 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,372 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 11 h 39 m 38 sec
Reputation Power: 383
please start a new thread for a new topic.
please read the information at my signature to post your code.

Look up the system command.

Meanwhile, if you're on Windows NT or perhaps other Microsoft systems, a c code like
system("start ie rocket.html");
might work.
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Threads in c language!!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap