Skip to main content
GameDev.net gamedev.net
🔒 Locked

Do you know Petri Net and/or modeling languages?

Started by riruilo Jan 25, 2010 at 3:04 PM 8 replies 1.5k views
Original Post
riruilo
riruilo
Hi friends! I'm just reading about servers and I'd like to know if you write MT servers directly (C++ or Java) or maybe you use any other high level tools/techniques. For instance, have you ever used a modeling language or Petri net to design you multithreaded server or any modeling language created for distributed systems? http://en.wikipedia.org/wiki/Petri_net Thanks a lot for help.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
jpetrie
jpetrie
Quote:

Petri net

Never heard of that before, but I'm going to find some way to take credit for it.
riruilo
riruilo
Quote:
Original post by jpetrie
Quote:

Petri net

Never heard of that before, but I'm going to find some way to take credit for it.


It seems it is a way to model servers (but I'm not sure). Something like using a finite state machine to model a NPC behaviour.

I'm interesting in very high level tools/methods to create servers (that can be checked) instead of writing them directly in java or C++ or something like ENET.

Thanks for reply.

[Edited by - ricardo_ruiz_lopez on January 25, 2010 6:12:19 PM]
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Antheus
Antheus
Simple reality of software development is that is has become a commodity. This type of abstract concepts have no application in world where time to market is measured in days, and obsolescence in months.

There might be places which actually require and can benefit from this type of formal verification, but given the burden it places on development, and lacking automated verification (to my knowledge), there is simply no place to apply it.

In practice, this type of guarantees will be provided in form of various design patterns, frameworks, or enterprise-grade software.

A few years ago I read a similar proposal for design of large-scale enterprise systems, but my impression is that it went the way of UML.

Main problems with this approach is the latency it introduces into development process, which directly conflicts with various agile or feature change cycles, as well as generally being too formal for practice.

There exist formal software verification methods for other types of design as well, yet even unit testing is frequently misapplied, and peer reviews are an oddity.

The gap between CS and actual software development has just gotten too big. Until someone provides this type of tool as an Ant task it simply isn't viable. And even then it lacks adequate value - formal correctness carries next to value in real world.

Simple proof: how much of single-threaded, non-distributed code is formally verified? A process which could be considered much simpler, and for which automated solutions do exist.
hplus0603
hplus0603
Quote:
formal correctness carries next to value in real world


Formal methods prove that the program implements your specifications (for whatever expressiveness the formal specification language has). This can, at times, be useful, as it may weed out implementation bugs (as opposed to requirements or specification bugs).

However, once the expressiveness of the formal language is enough to actually prove that the system *works*, the formal language is just another computer language...

The best way I know of making sure things work, and keep working, is to develop in a framework of test cases. Start by writing a simple log-in test case (hit a URL, fill out two fields, press submit). Verify that it can log you in. If not, fix the system until you can. Now, repeat for each kind of function your system needs.
The nice thing about automated tests is that they will immediately tell you when something doesn't work right.
enum Bool { True, False, FileNotFound };
riruilo
riruilo
Antheus, formal methods are used in aircraft industry and any other critical software (nuclear facilities, airports...)

Anyway, I'm not taking about formal methods (that are used in some industries) or correction, actually I'm looking for a more automatic way to create servers. A different way to create multithreaded servers where I spend my time in business logic rather than locks/semaphores/deadlocks/threads...

I read an article that EVE servers were create Python Stackless, instead of C++ or Java, and I guess probably is easier to implement. Maybe this is a first step.

I use a UML modeler to develop my state charts (FSM) that sometimes have 50 states or more, without modeling it is very easy to make mistakes, specially when you modify it (add or remove states).

So, in other words, do you know any other way to create MT servers rather than writing tons of code of C++ or Java? (where, BTW, a concurrency mistake can be very expensive to fix, or even find, if you can)

Thanks for ideas.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
hplus0603
hplus0603
Quote:
A different way to create multithreaded servers where I spend my time in business logic rather than locks/semaphores/deadlocks/threads


Isn't that exactly what J2EE and servlet servers (like Tomcat) and ASP.NET and other application servers/frameworks do for you? Pick one, and run with it.
enum Bool { True, False, FileNotFound };
riruilo
riruilo
Quote:
Original post by hplus0603
Quote:
A different way to create multithreaded servers where I spend my time in business logic rather than locks/semaphores/deadlocks/threads


Isn't that exactly what J2EE and servlet servers (like Tomcat) and ASP.NET and other application servers/frameworks do for you? Pick one, and run with it.


I will read about that. No idea about J2EE at the moment.
Thanks.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
tomva
tomva
I'm not aware of any high-level approaches that make multithreaded game server development easier, without sacrificing either performance or flexibility or both.

I have used Petri Nets! It took me a while to remember. They are pretty handy for workflow modeling but I haven't seen them used for multithreading myself. And even in production environments, running transitions in parallel was sometimes not worth the support costs vs performance wins.

If you are working in a for-profit company: yes, programming is a commodity, and you'll probably be building (or working on) a custom engine where careful modeling and CS correctness aren't top priority.

However, if for open source or leisure, you have more options. I myself opted for a much simpler threading model, to balance performance (necessity for multithreading) and maintainability (I think it could become very expensive to debug multithreaded programs with multiple contributors). So you may want to enforce a model just to keep complexity down to a maintainable level.

You can see my simple model here. In a nutshell, I require all shared collections to synchronize themselves, and there should never be multiple locks held by one thread at the same time. I have no idea if that is a good model or not, but it is simple and has served me well so far.

Even if you can't do anything formally, I do recommend having a documented strategy so that different developers can follow the same pattern.
riruilo
riruilo
Quote:
Original post by tomva
I'm not aware of any high-level approaches that make multithreaded game server development easier, without sacrificing either performance or flexibility or both.

I have used Petri Nets! It took me a while to remember. They are pretty handy for workflow modeling but I haven't seen them used for multithreading myself. And even in production environments, running transitions in parallel was sometimes not worth the support costs vs performance wins.

If you are working in a for-profit company: yes, programming is a commodity, and you'll probably be building (or working on) a custom engine where careful modeling and CS correctness aren't top priority.

However, if for open source or leisure, you have more options. I myself opted for a much simpler threading model, to balance performance (necessity for multithreading) and maintainability (I think it could become very expensive to debug multithreaded programs with multiple contributors). So you may want to enforce a model just to keep complexity down to a maintainable level.

You can see my simple model here. In a nutshell, I require all shared collections to synchronize themselves, and there should never be multiple locks held by one thread at the same time. I have no idea if that is a good model or not, but it is simple and has served me well so far.

Even if you can't do anything formally, I do recommend having a documented strategy so that different developers can follow the same pattern.


It seems interesting.
I'm doing this just for pleasure (at the moment), no dead-lines. Anyway, I think correctness in a MT server must be interesting, just because bugs in that kind of program can be painful. Thanks for link.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.