473,395 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem regarding process

HI,
I have to implement a program using exec command to illustrate
concurrent and sequential process. What I did is just create two input
file

Alpha.txt
========
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
. . .
abcdefghijklmnopqrstuvwxyz (upto 50 lines)

Number.txt
========
1234567890
1234567890
1234567890
. . .
1234567890 ( upto 50 lines)
my code is
========
#include <sys/types.h>
#include<unistd.h>
#include<iostream>

using namespace std;

int pid1,pid2;

int main ()
{

pid1 = fork(); //first child process

if (pid1<0){

perror("error");

}

if (pid1 ==0)
{

execl("/bin/cat","cat","Alpha.txt",NULL);

}
//parent process

if (pid1>0) {

}

pid2 =fork(); //second child process

if (pid2==0){

execl("/bin/cat", "cat","Number.txt",NULL);
}

if (pid2>0){
}
}
output ( I want output in this manner)
===========================
For Concurrent process:-

abcdefghijklmnopqrstuvwxyz
1234567890
abcdefghijklmnopqrstuvwxyz
1234567890
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
1234567890
..................... ( this its goes one)

but i am getting all the alphabets first then number( they are not
overlapping which it should happened in concurrent)
For Sequential process :

I want all alphabets then number

please help me, Thanks in advance

Sep 23 '07 #1
1 1711
On 2007-09-23 11:02, Bhavin wrote:
HI,
I have to implement a program using exec command to illustrate
concurrent and sequential process. What I did is just create two input
file

Alpha.txt
========
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
. . .
abcdefghijklmnopqrstuvwxyz (upto 50 lines)

Number.txt
========
1234567890
1234567890
1234567890
. . .
1234567890 ( upto 50 lines)
my code is
========
#include <sys/types.h>
#include<unistd.h>
#include<iostream>

using namespace std;

int pid1,pid2;

int main ()
{

pid1 = fork(); //first child process

if (pid1<0){

perror("error");

}

if (pid1 ==0)
{

execl("/bin/cat","cat","Alpha.txt",NULL);

}
//parent process

if (pid1>0) {

}

pid2 =fork(); //second child process

if (pid2==0){

execl("/bin/cat", "cat","Number.txt",NULL);
}

if (pid2>0){
}
}
output ( I want output in this manner)
===========================
For Concurrent process:-

abcdefghijklmnopqrstuvwxyz
1234567890
abcdefghijklmnopqrstuvwxyz
1234567890
abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
1234567890
..................... ( this its goes one)

but i am getting all the alphabets first then number( they are not
overlapping which it should happened in concurrent)
For Sequential process :

I want all alphabets then number

please help me, Thanks in advance

First of, you are off topic in this group since what you are using and
seeing are platform specific. Your problem is that your files are quite
small and the scheduler does not have time to make a process switch
before the fist cat has finished (I'm not sure but I think many
schedulers give new processes a bit of extra time). I think the best
solution would be to make the files much larger, 500 or 5000 lines and
redirect the output to a file (beware of file locking).

--
Erik Wikström
Sep 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
23
by: Rudolf Bargholz | last post by:
Hi, I have a ralatively simple SQL: select FK from TABLE where upper(A) like 'B%' and upper(C) like 'D%' We have DB2 UDB v7.1 FP 12 installed on Linux and on Windows 2003 On Linux using...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
0
by: ALI-R | last post by:
I am using the code below to open Outlook as user clicks on "Email this page" try { string subjectEmail=string.Format("Magnet Alert Center - Alerts for : {0}",Request.QueryString);
1
by: trialproduct2004 | last post by:
Hi all, I am having slight confusion regarding memory management in .net. Say suppose i have two application one is in C# and other is in MFC(VC++). Both of this application are using lots...
39
by: Marcin Zmyslowski | last post by:
Hello all! I have the following problem with MS Access 2003 permissions. I have two users. One is admin and the second one is user who has full permissions to enter modify and read data. I...
14
by: Rene Grothmann | last post by:
I have managed to communicate between forms and Java applets. A button press sends the content of the text area to an applet, a second button gets some text from the applet and puts it into the...
1
by: alik | last post by:
I am having problem with understanding the project's concept and what exactly we need to follow. I don't know if we have to create files and how many. This is my first programing experience and I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.