Controlling child processes


 
Thread Tools Search this Thread
Top Forums Programming Controlling child processes
# 22  
Old 04-19-2004
No problem. All this is very interesting stuff to me. I've been toying a lot lately with multi-threaded (rather than multi-process) stuff and it gets interesting.

All you really need to know, however, is that whenever there exists the potential for two processes/threads to access a resource at the same time, you need synchronization.

Of course, as I said before tuning that is, IMO, the biggest cause of headaches.

I.E. Its easy for two processes to synchronize on an "entire database", but that's slow. So you make them able to synchronize on a "single row" and that speeds things up but introduces other potential problems (deadlocks).

Meh, this is all really outside the scope of this thread any more...but process/resource synchronization is a very interesting, IMO, topic of discussion. You should be glad you get to toy with it in a learning environment...my school never taught us a thing about it (believe it or not).
# 23  
Old 04-19-2004
It is actually a Operating system course and all the major topics mentioned we have studied; on an academic level I understand it, however implementation is something different. In regards to deadlocks I do not know if this helps, however the Bankers algorithm may be a start (lots of overhead and predefined info is needed). Do not beat yourself up about the deadlock issue even the big boys (Oracle) occasionally end up in this state and most Operating systems including UNIX ignore it. Do you know the type of deadlock that is being encountered i.e. mutual exclusion, hold and wait, circular waiting or non preemptive (Studied for a final, it is fresh in the noggin)?
FI
# 24  
Old 04-19-2004
Quote:
Originally posted by forumGuy
It is actually a Operating system course and all the major topics mentioned we have studied; on an academic level I understand it, however implementation is something different. In regards to deadlocks I do not know if this helps, however the Bankers algorithm may be a start (lots of overhead and predefined info is needed). Do not beat yourself up about the deadlock issue even the big boys (Oracle) occasionally end up in this state and most Operating systems including UNIX ignore it. Do you know the type of deadlock that is being encountered i.e. mutual exclusion, hold and wait, circular waiting or non preemptive (Studied for a final, it is fresh in the noggin)?
FI
Actually I myself am not encountering any problems with deadlocks. Although I understand them quite well, and am familar with the banker's algorithm. However, I'm lucky in that I don't need it because I am in complete control of my resources and can simply generate (and strickly follow) locking rules that guarentee I won't deadlock.

In my case, this is simple. In the case of an OS or DB, it's not so simple because you're not in complete control over what the end interface (process/client) will request or do with the resources. Funny enough that in these circumstances the Banker's Algorithm is generally of no help because most of the time the OS/DB has no knowledge of what resources are going to (or ever will be) requested by the processes/clients that it is scheduling. Therefore, this renders the Banker's Algorithm useless, as it requires all processes to notify the scheduler of all its resource requirements before entering a "critical section" and unless the OS/DB places strict requirements on its interface (which they'd prefer not to do) they can deadlock and there's nothing that can be done about it besides detect it and tell the application that it must correct it.

In *nix, the EDEADLK errno is set in response to the failed system call that generated the potential deadlock. The application then can either die, release resources and try again, or just spin trying infiniately and hoping that the condition is corrected (which is unlikely).

In Oracle, the deadlock is detected and broken by automatically "rolling back" the client having less work done at the time of detection. Afterwhich, the client can attempt to re-do all its work from the beginning again.

Neither of these are "faults" of the OS/DB, but just inherient issues due to the fact that they can not predict the resource usage of their clientelle (ironic in that Oracle's name suggests that it should be capable of doing so however Smilie.)

Anyway, be greatful that your OS course is actually making you implement or play with these things in code. Theory means little without any hands on knowledge. In my opinion, too many schools teach theory without ever giving students practical work that makes use of it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get all child processes of a process

is there a universal way of getting the children of a particular process? i'm looking for a solution that works across different OSes...linux, aix, sunos, hpux. i did a search online and i kept finding answers that were specific to Linux..i.e. pstree. i want to be able to specify a process... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

Controlling the Number of Child processes

I am trying to implement the below using Ksh script on a Lx machine. There is a file(input_file) with 100K records. For each of these records, certain script(process_rec) needs to be called with the record as input. Sequential processing is time-consuming and parallel processing would eat up... (2 Replies)
Discussion started by: APT_3009
2 Replies

3. Windows & DOS: Issues & Discussions

Controlling AIX processes remotely using a NET app on a Windows server?

I have a .NET application that remotely starts, stops, and gets status of Windows services and scheduled tasks. I would like to add the capability of starting, stopping, and getting status of remote AIX applications also. Based on some preliminary research, one option may be to use 3rd party .NET... (0 Replies)
Discussion started by: auser1
0 Replies

4. Programming

Controlling a child's stdin/stdout (not working with scp)

All, Ok...so I know I *should* be able to control a process's stdin and stdout from the parent by creating pipes and then dup'ing them in the child. And, this works with all "normal" programs that I've tried. Unfortunately, I want to intercept the stdin/out of the scp application and it seems... (9 Replies)
Discussion started by: DreamWarrior
9 Replies

5. UNIX for Advanced & Expert Users

killing all child processes

Hi, Is there a way I can kill all the child processes of a process, given its process id. Many thanks in advance. J. (1 Reply)
Discussion started by: superuser84
1 Replies

6. Shell Programming and Scripting

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n",... (1 Reply)
Discussion started by: green_dot
1 Replies

7. Programming

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n", getpid(),... (0 Replies)
Discussion started by: green_dot
0 Replies

8. Shell Programming and Scripting

Parent/Child Processes

Hello. I have a global function name func1() that I am sourcing in from script A. I call the function from script B. Is there a way to find out which script called func1() dynamically so that the func1() can report it in the event there are errors? Thanks (2 Replies)
Discussion started by: yoi2hot4ya
2 Replies

9. UNIX for Dummies Questions & Answers

what are parent and child processes all about?

I don't follow what these are... this is what my text says... "When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)
Discussion started by: xyyz
1 Replies

10. UNIX for Dummies Questions & Answers

Controlling processes knowing the PID's

Dear all, suppose that I start a process (named "father"). "father" starts in turns a process called "child" with an execv call (after a fork). In this way "father" will be notified if "chlid" crashes (SIGCHILD mechanism). The problem is: if "father" crashes, how can I do to be recreate a... (1 Reply)
Discussion started by: npalmentieri
1 Replies
Login or Register to Ask a Question