• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 131
  • Last Modified:

Class execution help

Hi,

I have a working client/server (Active X) system at the moment, but don't quite have the pc's to perform/"know how" this little test.

If clients simultaneously attempt to execute functions on their respective server class instances, which of the following will it do ?

1.  One client complete it's transaction before the next is started, ie FIFO.

2.  Execute them both simultaneously.

If it is case 1 then there is no problem.  If it is case 2, that is another matter.  I would need to implement semaphores to ensure that another client doesn't poison the shared data another instance could be working on.

Thanks in advance.

aho.
0
aho1
Asked:
aho1
  • 3
  • 2
  • 2
1 Solution
 
corvanderlindenCommented:
1. Do your clients all use the same class in the server

2. Is the class in the server single- or multiuse
0
 
GordonpCommented:
If the clients are using seperate instances of the Server Class ( ie each used set Server = new Server class )

then it is down to how you set the threading properties in the ActiveX Executable

As long as you have at least as many threads as clients then you have no problem.

each Instance runs simutaneosly but seperately. Both instances have there own copy of any global data so no semaphores etc. are required.

How many threads have you?

If you've set the Threading Model to Thread per Object your OK, your Exe will have a seperate thread for each instance.

If you've set it to Thread Pool then the number in the text box tells you how many threads you have.

If you only have 1 thread then its not FIFO but LIFO ( Last in First Out ).

If need more info let me know

Hope this helps

Gordon
0
 
corvanderlindenCommented:
If your shared data is for instance a file our a MMF you are in trouble anyway
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
aho1Author Commented:
Gordonp, Thanks for your reply.

Will the class instances execute simultaneously with the On_COMM Event that is in the server module?  

aho.
0
 
GordonpCommented:
If both are trying to listen to the same comm port, then you may have a problem.

As I said each instance sits on its own thread with its own copy of the global data, this includes forms , AND controls.

So you now in effect have two MSComm controls trying to access a single comm port.

It wont work I'm afraid. You may need to stick with a Single Thread ( Thread Pool of 1 ) and set up a Queing system to get FIFO instead of LIFO.

Gordon

0
 
corvanderlindenCommented:
Sorry guys, but I said it before: if you are sharing 1 resource (file, port or whatever) you have a problem and should implement a pooling object or use semaphore or mutex
0
 
aho1Author Commented:
Guys,
Assuming I use the pooling object method.

Is it possible to maintain a data received/sent/waiting queue in a module (as single instance) that opens the COMM port once and all the other class instances read data from those queues'.

If so, I might try to implement such a queue system,
 - Timestamp and ID all requests.
 - Place COMM sent/receveived in another queue
 - Prioritise data queues, for instance all COMM recevied data would be treated as highest priority.

Also where are some good semaphore implementation examples, I haven't seen it implemented under vb before.

Thanks, aho.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now