Home | Reviews | GUIpedia | Forum | Fun500


pharoahInter-Process Communication
I'm interested in implementing a system of inter-process communication in a GUI I am planning. I'm wondering if anyone here who has written a multi-scripting system of any kind had a facility for scripts to communicate. If so, how did it work?
2009-01-0810:54 PM

BrandonRe:Inter-Process Communication
That was going to be next in Fun500. I was thinking something along the lines of a child scripts though, basically for a file dialog it would share variable space with the script, that way the script could receive the filename.
2009-01-096:50 AM

Re:Inter-Process Communication
Yeah that was going to be part of my plan. Child scripts that multitask separately but share memory are called threads. Also I think I will implement some sort of message queue with interrupts in the programs. When a message arrives the script will pause and will run starting at the part it has specified as the message handler. For now I will just use pipes.
2009-01-0910:01 AM

trollyRe:Inter-Process Communication
you can use sharedmemory with peek and poke to write and read message. [url=http://7a1pjw.bay.livefilestore.com/y1pAZtnMkKXly2qFHDAm3j_PgG9zHqTZNqcl7eQ6Cdh3nqodzl6tNbSKimRcZTaQ2IRuDSgSYsBYqAaPLx0Z144Bg/SHAREVAL.BAS?download ]look this file[/url]
2009-01-0912:01 PM

SonicBritRe:Inter-Process Communication
IPC is fairly easy to implement as a message based system using a queue. You always put the new item at the end of the queue and the parent app always pulls new items off of the top of the queue. Its really your choice if the app is suspended after posting messages (until the new message is processed) or just carries on with what its doing. With windows programming you have to setup a loop getting messages and dispatching messages, this is due to windows relying on messages for every aspect of how the system works, I like VB's method of using events, (which is funny because the vbvm dll basically runs a message loop as required by windows and converts the messages into events)
2009-01-0912:51 PM

pharoahRe:Inter-Process Communication
Thanks for your reply sonicbrit, it's very interesting. I am wondering, if I implement a message queue how will scripts tell the GUI which other script they should communicate with. I guess the scripts could create a mailbox with a specific name, or I could give them numbers, or something else. Any idea how this is accomplished in existing systems?
2009-01-092:18 PM

trollyRe:Inter-Process Communication
in my own microkernel os, i implemented ipc so: step 1: mailbox creation ------------------------- a) Process A allocate memory for the mailbox b) the process register the mailbox by specifying the mailbox identifier and the buffer adress c) the kernel update the mailbox table (Id,buffer,owner) d) the process will be blocked until he receive a signal step 2 sending message ----------------------- a) Process B specify the mailbox identifier and the message to send b) the kernel look into the mailbox table to and find the buffer address and the owner of this mailbox c) the kernel push the content of the message with a header to the mailbox (in the first process addressing space) d) the kernel send a event to the owner of this mailbox step 3 getting message ---------------------- a) Process A get a event from the kernel witch signal him that he receive a mail (message) b) the process pops the received from the mailbox c) in the header of the message is the sender's ID, the process can send a signal to him to say that he receive the message step 4) unblocking sender ------------------------- a) Process B is waked with a event id b) if it's the correct event he continue, else he sleep against
2009-01-099:23 PM

pharoahRe:Inter-Process Communication
Okay maybe somebody will know this. I am trying to implement pipes (sounds simple right?), and I want them to be buffered. The pipe calling program can keep reading the output of the program it called as long as there are bytes in the buffer, and can keep sending out to the buffer. The problem is that, after the source program (the one called) closes, I want the calling program to still be able to read from the buffer but after that I want the buffer to disappear. I also want the write buffer (the stdin for the source program) to disappear as soon as the pipe closes. How do I handle this so that the calling script/program knows that the pipe is closed and not to read from or write to it anymore? EDIT: I've decided what I'll do is make pipes work like SHELL in DOS (sort of). They take a string of input as an argument, and when called they block the calling app until the source app is done, then pass a full string of output back. I can use threads and message queues for communication between running programs.
2009-01-103:19 PM

SonicBritRe:Inter-Process Communication
So yes pipes are similar to a file system, basically you have to think of it as one program opening a file to write to but allowing the file to be shared for reading. Whilst the other app opens it for read only. I don't remember if qb supports it, but in c you could effectively open the same file twice.
2009-01-124:42 PM

GUIs


2021 Brandon Cornell