LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


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

Rep: Reputation: 0
clone task will not give up processor


I am attempting to clone multiple tasks in the code below. However, when executing the first cloned task holds the processor forever. If I remove the while(1) in TaskTester, then each task is generated, but only after the previous task has completed. This is running TS-Linux or Debian Linux on an ARM. What am I doing wrong? (I added the sched_yield() but it didn't make any difference.




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

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();
// sched_getscheduler();
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);
}
 
  


Reply



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
Task bar no longer shows task Richard Rahl Linux - Newbie 3 04-12-2010 09:39 AM
cloned tasks will not give up processor StandardImpulsePower LinuxQuestions.org Member Intro 2 05-30-2007 03:35 AM
Give me a task/project to complete Melhisedek Linux - Newbie 12 10-21-2006 05:10 AM
Dual processor task distribution question sh_roohani Linux - Newbie 2 12-15-2004 11:56 AM
Can't add hard drive- simple task- about ready to give up linux saxblue Linux - Hardware 4 07-30-2003 11:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:58 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