implementation of all sorting algorithms using fork


 
Thread Tools Search this Thread
Top Forums Programming implementation of all sorting algorithms using fork
# 1  
Old 03-02-2005
Network 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  
Old 03-02-2005
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
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. AIX

Disable any 96-bit HMAC Algorithms

Received a vulnerability - SSH INSECURE HMAC ALGORITHMS ENABLED. The solution was to Disable any 96-bit HMAC Algorithms. Disable any MD5-based HMAC Algorithms. Can someone please tell me how to disable in AIX 5.3? Thanks, Sudo (1 Reply)
Discussion started by: sudo su
1 Replies

2. Homework & Coursework Questions

UNIX internal Algorithms

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Unix internal algorithms like namei() 2. Relevant commands, code, scripts, algorithms: System... (1 Reply)
Discussion started by: Phaneendra G
1 Replies

3. Programming

Algorithms for Parallel Processing

Hey, I just wanted to know how many algorithms there are that cannot be accelerated by parallel processing. I know one such algorithm is Euclid's Algorithm (for GCF). does anyone know any other algorithms that cannot be accelerated by pp? if so please list the names and a general sentence of what... (2 Replies)
Discussion started by: azar.zorn
2 Replies

4. UNIX for Advanced & Expert Users

password hashing algorithms

I'm collecting some info on the password hashing algorithms in use on various Unix systems. So far I have: no $ legacy unix crypt $1$ MD5 $2$ Blowfish on BSD $2a$ alternate Blowfish on BSD $md5$ Sun's alternate MD5 $3$ a Microsoft hash $4$ not used? $5$ RedHat proposed Sha-256... (2 Replies)
Discussion started by: Perderabo
2 Replies

5. Programming

Recommendations For Generic C Data Structures & Algorithms

Hi All, Rather than re-invent the wheel, I am trying to find a mature C library that provides generic support for lists, trees, etc. I understand C doesn't formally support "generics", but am aware of a few solutions like GLib and SGLib. Can anyone kindly recommend what they think is best?... (1 Reply)
Discussion started by: tristan12
1 Replies

6. UNIX for Advanced & Expert Users

Horizontal sorting of lines in a File: SED implementation?

Hi guys, Do you know how can I sort a file horizontally per line??? sample input file: zebra papa dog apple yahoo kangaroo ape sample output: apple dog papa zebra ape kangaroo yahoo Please post if u know the sed implementation of this (or whatever implementation u may know of)... (7 Replies)
Discussion started by: marlonus999
7 Replies
Login or Register to Ask a Question