Qbasicnews.com
October 15, 2018, 08:07:23 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Multiple windows / Multiple programs  (Read 8533 times)
wallace
Wandering Guru
***
Posts: 368



WWW
« on: January 27, 2007, 02:27:58 PM »

I have a main driver program that creates a number of threads, each thread uses the 'exec' command to open another program.  Some of the programs do calculations, others do graphics.  The driver program is in full screen mode.  The graphics programs use screenres but have the -1 flag (shouldn't make a window.)  When I run each program seperately, they do exaclt what I want them to, they do the graphics without a window and BSAVE the buffer to a file.

I want the driver to be able to get that BSAVEd file and load it on it's screen, which it can do.  The problem is that when I run the helper programs from the main one, the GFX_NULL (-1) flag doesn't seem to work and a window is created, forcing the main program to switch out of fullscreen mode and minimize.  

I have tried everything, I have the always on top flag on, the no switch flag, and the fullscreen one.

Is there a way to do what I want here?  I explained it the best I could, but it's a weird concept I know, let me know if you need help understanding what I'm doing.
Logged

f you play a Microsoft CD backwards you can hear demonic voices.  The scary part is that if you play it forwards it installs Windows.
LooseCaboose
I hold this place together
*****
Posts: 981



« Reply #1 on: January 28, 2007, 01:23:42 AM »

Why are you execing new processes inside of a thread? If you want a new process you should just call CreateProcess under Windows or fork/exec under Unix (check the man pages). You generally don't want/need to exec a new process from a thread unless the thread is also doing some other work.

I'm not sure how the screen mode thing works in FB. But typically when you fork a new process (I don't know the details of how Windows behaves for this) it makes an exact clone of the parent process. Possibly this is overriding the gfx flag somehow?

However, if you are trying to communicate between between each of the programs I would suggest just using threads. Communication between processes is usually a pain. You can use shared text files or memory maps (which is tacky and error prone), or something more complicated like pipes or sockets. With threads you have access to the same heap and using mutexes (see pthread_mutex_lock/unlock under Unix) you can do inter-thread communicate without race conditions fairly easily.
Logged

esus saves.... Passes to Moses, shoots, he scores!
wallace
Wandering Guru
***
Posts: 368



WWW
« Reply #2 on: January 28, 2007, 03:36:54 PM »

I can't just use threads because it it kind of like a cluster program, and the helper programs will be updated and deleted and new ones will be added.  

The program has to run under Linux so piping and CreateProcess is out.



EDIT:  I figured it out, the graphics window that I used the GFX_NULL flag on that I thought was the problem wasn't at all.  I was compiling the helper programs normally, so they made a new terminal window each time which was what bumped me out of fullscreen.  I simply added the -gui parameter to the compiler and it works perfectly.
Logged

f you play a Microsoft CD backwards you can hear demonic voices.  The scary part is that if you play it forwards it installs Windows.
LooseCaboose
I hold this place together
*****
Posts: 981



« Reply #3 on: January 29, 2007, 02:00:01 AM »

Quote from: "wallace"
   
I can't just use threads because it it kind of like a cluster program, and the helper programs will be updated and deleted and new ones will be added.


The only reason you shouldn't be able to use threads are if the helper programs are running on different machines. You can easily manage dynamic creation/deletion of threads.

Quote from: "wallace"

The program has to run under Linux so piping and CreateProcess is out.

CreateProcess is out. Pipes are definitely an option. However, if you are running multiple processes on different machines then you probably want to use sockets to communicate.
Logged

esus saves.... Passes to Moses, shoots, he scores!
wallace
Wandering Guru
***
Posts: 368



WWW
« Reply #4 on: January 29, 2007, 02:42:39 PM »

I'm intruiged, I don't use threading a lot so I'm a little rusty.  How do I create a thread out of a helper program in FB?  They will all be on the same machine.  
 
thread = threadcreate("test.exe", 0)?   I know that doesn't work, what do I need to do differently?

Will it cause problems if the helper program is also multithreaded?
Logged

f you play a Microsoft CD backwards you can hear demonic voices.  The scary part is that if you play it forwards it installs Windows.
LooseCaboose
I hold this place together
*****
Posts: 981



« Reply #5 on: January 29, 2007, 03:41:21 PM »

You need to give threads a function to start executing in, not an executable name (threads are lightweight processes). I don't code in FB, so I don't know what threading library it uses, but I would suggest using pthreads.

If you need to be able to swap the helper programs being executed then you can use a plugin architecture with dynamic libraries, see here.

You can have the threads you create also create their own threads. You do need to bear in mind though that all of the created threads will have access to the same heap and you need to be careful of race conditions and deadlocks.
Logged

esus saves.... Passes to Moses, shoots, he scores!
Anonymous
Guest
« Reply #6 on: February 15, 2007, 03:24:36 PM »

I'm 99% sure fb uses pthreads on linux, probably some winapi crap on windows, for speed.
Logged
D.slert
New Member

Posts: 7


WWW
« Reply #7 on: August 27, 2009, 07:58:45 AM »

I am not sure that you can actually do that, but you can place the icons for  those programs on in your quick start menu are place them on the Windows tool bar.   Also consider how many programs you have launched at startup.  Do you leave your computer on all the time?  How fast is your processer and how much ram do you have running.  Also have you checked the stats of background programs running on your system?  Is your complaint that to lauch all the programs takes too long?  Because it shouldnt.

I am a huge ebayer myself and I use all the same programs as you do save for IE, I  prefer mozilla.  I have no problem launching each of these programs one after the other.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!