Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple windows / Multiple programs
#1
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.
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.
Reply
#2
Why are you execing new processes inside of a thread? If you want a new process you should just call [url="http://msdn2.microsoft.com/en-us/library/ms682425.aspx"]CreateProcess[/url] 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.
esus saves.... Passes to Moses, shoots, he scores!
Reply
#3
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.
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.
Reply
#4
Quote:
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: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.
esus saves.... Passes to Moses, shoots, he scores!
Reply
#5
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?
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.
Reply
#6
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.
esus saves.... Passes to Moses, shoots, he scores!
Reply
#7
I'm 99% sure fb uses pthreads on linux, probably some winapi crap on windows, for speed.
Reply
#8
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)