Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ smaug processess and multi tasking?
smaug processess and multi tasking?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nargsbrood
(54 posts) Bio
|
Date
| Fri 06 Oct 2006 04:23 AM (UTC) Amended on Fri 06 Oct 2006 04:26 AM (UTC) by Nargsbrood
|
Message
| i've always wondered this and want to know if anyone has any insight on this:
how does smaug seemingly multi task? for example,
as an imm i will type prac and hit enter getting a list of all the spells/skills in game. isnt the program occupied with this process? how is it that i can toggle over to other char and be able to interact with mud while the other player is still recieving info for skill/spells?
shouldnt the program itself be occupied in do_practice and therefore not be able to answer requests recieved?
i hope my question makes sense.
all i can think of is there is something sperate in the tcp/ip protocols that acts as a buffer that is independent from smaug.exe and it's processes? | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Fri 06 Oct 2006 04:33 AM (UTC) |
Message
| You mean, while the input is still scrolling along? The server buffers it, so it can gradually be sent while it is doing other things.
It is part of the main tcp/ip loop, that it pulls in packets (which might be part of a command) and waits for a linefeed until it does anything, and also sees if there is outstanding stuff to be sent. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Gohan_TheDragonball
USA (183 posts) Bio
|
Date
| Reply #2 on Fri 06 Oct 2006 05:56 AM (UTC) Amended on Fri 06 Oct 2006 05:58 AM (UTC) by Gohan_TheDragonball
|
Message
| from what i can gather:
game_loop:
1) check for new connection (descriptor)
2) loop through descriptors
a) check for idleness
b) check for command pause
c) no pause, read all input from descriptor, interpret next command in line
3) update entire mud via update_handler
4) loop through descriptors again now that we've kicked off everyone who shouldn't be on
a) print 512 bytes of current waiting output to the descriptor, the 512 is dependent on
if you use the client speed snippet or not, i use it, and it works awesome if ya haven't
tried it i suggest lookin at it
5) game stuff, syncronize to a clock, check descriptor links, etc
6) repeat
so yes any function takes complete priority, as that is how computers work per thread (from what i remember muds are all single threaded), however the output from any function in the game does not instantly send the data to the player, which is how you get your screen still scrolling and able to interact on a seperate character. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #3 on Fri 06 Oct 2006 10:02 PM (UTC) |
Message
| Well, there's also the fact that the game is simply fast enough to allow this kind of seeming interaction. Don't forget that a single-processor machine is doing massive amounts of multi-tasking, and yet all programs seem to be running simultaneously. Having several programs running at once is really just an illusion of sorts.
Basically the key in SMAUG is what Nick said; the operating system handles receiving and sending TCP/IP packets, so once SMAUG writes them out it doesn't have to worry about them anymore. That is how the SMAUG code is able to appear fluid -- it doesn't have to wait for a packet to be sent before being able to move on.
But, as you type 'prac', the entire MUD does indeed pause while the MUD puts the results of that command into your buffer, and tells the operating system to send it over the network. It's just that that process is so fast that nobody really notices it. You'd need a fairly slow machine (i.e. from probably more than 10 years ago) for things to start being really noticeably slow.
That being said, the SMAUG way of handling networking is not ideal. There have been several discussions of that on these forums, if you are interested in that. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
13,842 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top