Error Return Code From Pthread_create Is 12
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us pthread create detached thread Learn more about Stack Overflow the company Business Learn more about hiring developers
Pthread Create And Join
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack pthread create mutex Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Why does pthread_create() return 12? up vote
C++ Pthread Create
0 down vote favorite 1 For some reason, pthread_create isn't allowing me to pass a struct as an argument. The issue is not system related, although I have not had a chance to test it on anyone else's box. It simply won't allow me to pass a struct for some reason; it returns error #12. The issue is not with memory. I know 12 is ENOMEM, and create pthread in c example "that should be that", but it's not.. it simply won't accept my struct as a pointer. struct mystruct info; info.website = website; info.file = file; info.type = type; info.timez = timez; for(threadid = 0; threadid < thread_c; threadid++) { // printf("Creating #%ld..\n", threadid); retcode = pthread_create(&threads[threadid], NULL, getstuff, (void *) &info); //void * getstuff(void *threadid); When I ran this code in GDB, for some reason, it didn't return code 12.. but when I run it from the command line, it returns 12. Any ideas? c pthreads share|improve this question edited Dec 31 '11 at 4:18 Jonathan Leffler 439k62510823 asked Dec 31 '11 at 3:58 Saustin 432720 The argument to the thread routine getstuff() is the pointer to &info, which is not a thread ID, despite your comment that its argument is a 'threadid'. You're probably aware of this, but just double checking. –Jonathan Leffler Dec 31 '11 at 4:16 Suppose you pass a null pointer instead of the address of info; you could make info into a global variable since the threads all use the same information - just don't modify it in any of the threads. Do you still run into memory problems?
HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Non-*NIX Forums > Programming pthread_create Cannot allocate memory error code 12 User Name Remember Me? Password Programming This forum is for
Pthread Key Create
all programming questions. The question does not have to be directly related to Linux
Pthread Lock
and any language is fair game. Notices Welcome to LinuxQuestions.org, a friendly and active Linux Community. You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and http://stackoverflow.com/questions/8686171/why-does-pthread-create-return-12 absolutely free. Join our community today! Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Are you new to LinuxQuestions.org? Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here. Having a problem logging in? Please http://www.linuxquestions.org/questions/programming-9/pthread_create-cannot-allocate-memory-error-code-12-a-486157/ visit this page to clear all LQ-related cookies. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click Here to receive this Complete Guide absolutely free. Search this Thread 09-22-2006, 09:28 PM #1 goodman888 LQ Newbie Registered: Sep 2006 Location: HK Posts: 3 Rep: pthread_create Cannot allocate memory error code 12 every time I run the following code, it will stop at i=303, i.e. only 303 threads can be created. I searched Google with my best and couldn't find the answer. There were similar cases reported but no answers.... hope someone can help... Code: struct Threadargs { int seq; }; void getCurrentDateTime(char *sdate
errors while compiling From: Afflictedd2