Hi, so I've got this program("main") that fork executes another ("user"). These programs communicate through fifos.
One communication is a spawn call, where user passes an executable, main forks and executes it. So, I'm keeping track of all my processes using a task table. After the fork (for the spawn call), the new child adds itself to the task table and then waits for the "user" to finish before executing. So, the user finishes what it needs, calls the end method on "main", which checks to see if there's a waiting process. It turns out when I show() my task table, the new child that I added isn't there! I can't figure out why at all. Any ideas?
Here's the 2nd child when it gets created.
Here's the output.
+ main + forking
+ TaskTbl + set(01, 19976) method called
+ TaskTbl + (01, 19976) added
<TaskTbl> has 2 items
0: <00,19975>
1: <01,19976>
+ main + waiting for system call message
+ user1 + calling s_end()
+ main + syscall task end received
<TaskTbl> has 1 items
0: <00,19975>
the end function is called immediately after the spawn function finishes, and I've checked everywhere to find something that would remove the task but the only way to do so would be for me to intentionally remove it ( remove -> (task, proc)), which I'm not doing.
I have no idea why the table is only showing 1 item immediately after. Help would be greatly appreciated.
Hi,
I am not getting a clear idea of what is happening.
Do you mean to say that the child part of fork is never executed?
or is it executed only once. Is show() by any chance using an exec function.
so program starts, main forks and executes child1, there's some communication, child1 sends a spawn message to main, but the new child needs to wait until the first child finishes. So, main forks, new child adds itself to the task table and begins to wait until child1 is finished. Main proceeds with child1 until it's done. Immediately after child1 is done, the new child executes child2, etc. I need to tell my main that there is a child waiting, and the order of execution so I use a task table. problem is after child1 is done, while new child (not yet executed child2) is waiting, main checks tasktable to see if there's another entry, which for some reason there isn't, but there should be.
and no, show is a call to TaskTable class which just displays entries. Any more questions just ask. Thanks for help.
the only array index is inside tasktable, which i've tested on a nonforking program multiple adds and removes, etc. and it all works fine. updating it with 2 processes apparenlty doesn't share.
Tell me something, after the first child proc has finished executing, it should *not* show up in the task table right? and you should see the second one? or is the task table supposed to have all entries at all times?
Is this table in explicitly shared memory? If not, each process gets it's own copy along with it's own independent memory space. Changes in one won't change any of the others. This is very different from threading, where everything lives in the same memory space.
Last edited by Corona688; 10-02-2005 at 03:15 AM..
Hi guys,
thanks for your kind assistance. I have a rhel6.4 server. After I did an update, the server does not reboot. Also user logins take for ever.
Please any help on this matter will be appreciated .
Thank you (2 Replies)
I want to have a message send & receive through 2 uni-direction FIFO
Flow of data
FIFO1
stdin--->parent(client) writefd--->FIFO1-->child(server) readfd
FIFO2
child(server) writefd2---->FIFO2--->parent(client) readfd2--->stdout
I need to have boundary structed message... (3 Replies)
I was asked to look into a problem with a Sun Netra 440 in another department. On the server in question, the relevant 'uname -a' information is, "SunOS host1 5.9 Generic_118558-16 sun4u sparc SUNW,Netra-440". That information aside, while the other admin is logged into the ALOM, these errors are... (0 Replies)
Is there a performance advantage of one of these over the other? Obviously, it makes no sense to use normal TCP sockets or UDP sockets w/ the overhead they carry. But what about UNIX domain sockets vs FIFOs? I'd think they'd be very similar, in terms of performance and in terms of how they're... (2 Replies)
i'm tring to make 2 processes each read from the same file but only one of them read the file.
FILE * fileptr1;
fileptr1 = fopen("file1.txt","rt");
pid2=fork();
while(1)
{
fscanf(fileptr1,"%s",temp1);
if(feof(fileptr1)==0)
{
printf("%i",getpid()); //id of current process ... (6 Replies)
I am trying to figure out why when i have the following code
int main( { printf("0\n"); fork(); printf("1\n"); exit(0);}
and type in the shell
a.out | cat
the output of this program is
0
1
0
1
instead of
0
1
1
does anyone know? (3 Replies)
This isn't strictly a Linux question, but... I've been working on a project to archive some streaming media for time shifting using 'mplayer' and have been using FIFOs to archive in Ogg Vorbis format:
mkfifo program_name.wav
(mplayer -ao pcm -aofile program_name.wav &)... (0 Replies)
omg i need help so bad. I've been working on a school project for what seems like an eternity and i'm close to deadline. Using FIFO's (i ahve to) to communicate between parent and child proc's. Right now I'm stuck on a read/write.
fifomsg is a struct with int length and char message fields. ... (5 Replies)
Hey guys,
I'm given this bit of code, but, I'm having some problems executing it with the functions I've defined so far. I'm suppose to define the funtions "parse" and "execute." Parse splits the command in buf into individual arguments. It strips whitespace, replacing those it finds with NULLS... (3 Replies)