The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Universal algorithms for channel decoding of uncompressed sources iBot UNIX and Linux RSS News 0 02-22-2008 05:50 AM
Horizontal sorting of lines in a File: SED implementation? marlonus999 UNIX for Advanced & Expert Users 7 03-19-2007 03:03 AM
need help with my implementation of cat in bash sanchopansa Shell Programming and Scripting 4 10-18-2006 07:28 AM
Solaris Timer Implementation ulisses0205 High Level Programming 2 04-06-2004 02:03 PM
Shell Implementation clickonline1 UNIX for Dummies Questions & Answers 3 10-02-2001 05:52 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-02-2005
chaitu07 chaitu07 is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 2
Angry implementation of all sorting algorithms using fork

im new to programming c in unix

this is program written by me i want each and every child to do a seperate work such implement a different sorting algorithm but im not getting the way i wrote as below...plz help me how can i do that

#include<stdio.h>
main()
{
int i;

for(i=0;i<5;i++)
{
fork();
child(i);
exit(0);
}
}
child(int j)
{
switch(j)
{
case 0: printf("iam child1 %d\n",j);
break;
case 1: printf("iam child 2 %d\n",j);
break;
default: printf("iam other\n");
}
return;
}

i want child 1 to execute case 1 child 2 to execute case 2....but all childs are executing only case 0

thank u

Last edited by chaitu07; 03-03-2005 at 02:18 PM.. Reason: i have implemented as u said but im not getting
  #2 (permalink)  
Old 03-02-2005
odys odys is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 59
Seems you need to start several processes with different sorting methods.
If you need to compare times you can write separate programs and use
'time' for measuring their speed.

But if you really need do start several functions in separate processes
the you can use fork() inside loop. Parent will continue loop while child
should break it. Read fork() manual.

Regards
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0