LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > LinuxQuestions.org > LinuxQuestions.org Member Intro
User Name
Password
LinuxQuestions.org Member Intro New to LinuxQuestions.org? Been a long time member but never made a post? Introduce yourself here.

Notices


Closed Thread
  Search this Thread
Old 05-29-2007, 01:43 PM   #1
StandardImpulsePower
LQ Newbie
 
Registered: May 2007
Posts: 2

Rep: Reputation: 0
cloned tasks will not give up processor


When running this test code, the first created clone will not give up the processor. The remaining tasks are never created.

If I take the while(1) out of the TaskTester(), then each task will be created in order, but only after the previous tasks have ended. I added the sched_yield() call, but nothing changed.

This is running TS-Linux or Debian Linux on an ARM processor.

I am not interested in the tasks sharing resources. Am I using clone incorrectly?
Thanks

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sched.h>

#define TASK_COUNT 3

int TaskTester(void * dummy)
{

if(dummy != NULL)
{
while(1)
{
// do something here
write(STDERR_FILENO,"Task ",5);
write(STDERR_FILENO,(char *)dummy,1);
write(STDERR_FILENO," reporting\n",12);
sched_yield();
sleep(10);
}
write(STDERR_FILENO,"Task ",5);
write(STDERR_FILENO,(char *)dummy,1);
write(STDERR_FILENO," exiting\n",12);
}
return(*((int *)dummy));
}

int main(void)
{
void *stack, *none;
char stack_mem[100];
int task_count;
pid_t pid;
char temp = 'A';

stack = (void *)&stack_mem[0];
none = (void*)&temp;
for(task_count = 0; task_count < TASK_COUNT; task_count++)
{
temp = (char)('A' + task_count);
if( (pid = clone((void*)TaskTester((void *)none),(void*) 0L,0,0)) == 0)
{
write(STDERR_FILENO,"ERROR: clone failed\n",21);
exit(1);
}
else
{
write(STDERR_FILENO,"Parent task sees creation pid\n",26);
fprintf(stderr,"Parent sees child pid = %ld\n",(long)pid);
}
}

return(0);
}
 
Old 05-29-2007, 02:22 PM   #2
hacker supreme
Member
 
Registered: Oct 2006
Location: As far away from my username as possible
Distribution: Gentoo
Posts: 259
Blog Entries: 1

Rep: Reputation: 31
Please don't post in more than one forum.

This copy has been reported for closure.
 
Old 05-30-2007, 03:35 AM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Closed as per above.
 
  


Closed 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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Use graphics processor to do other tasks? Oxagast Linux - Hardware 1 06-18-2006 05:57 AM
gentoo + cloned nic's kurrupt Linux - Networking 1 04-25-2006 03:05 AM
Setup cloned monitor hypoglycemic Linux - Hardware 3 08-05-2005 12:50 PM
Cloned CD problem,K3B. akihandyman Mandriva 3 01-08-2005 04:58 PM
xinetd 100% utilization on one processor on a two processor system red hat 9 garnold Linux - General 0 02-02-2004 01:47 PM

LinuxQuestions.org > Forums > LinuxQuestions.org > LinuxQuestions.org Member Intro

All times are GMT -5. The time now is 10:41 PM.

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