• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

khirsah

CPU utilization?

7 posts in this topic

Hiya, I''m trying to implement a client-server model where the server is run as a separate application (even for a client and server on the same machine). The thing works, but even with a simple (empty) main loop, CPU utilization hits the roof, which is less than ideal for a singleplayer loopback-type game. I''ve noticed that with "dedicated servers" in most games, CPU utilization sits pretty low. This is probably something elementary in Windows programming, but it''s eluded me completely...so what''s involved in affecting CPU usage for a given application? Is this a Win9x-specific thing (ie. would NT''s multitasking have the same results)? Help would be greatly appreciated!!
0

Share this post


Link to post
Share on other sites
By empty loop do you mean literally something like:

while (true) {
//no body
}

If so, of course CPU utiliziation is going to go through the roof! It''s going to spend all it''s time executing jmp statements. Once you start throwing in networking calls, it''s going to wait on the calls, dropping your CPU utilization immensly.
0

Share this post


Link to post
Share on other sites
Oh okay, but I''m still not clear...does that mean having to make the replies between client and server synchronous? At the moment the loop just progresses if no data is waiting.
0

Share this post


Link to post
Share on other sites
So are you just using send()/recv() statements within a while loop? Are you using any form of the select statement?

If you''re using some version of select you shouldn''t get that kind of CPU utilization.
0

Share this post


Link to post
Share on other sites
Thanks for your help - I finally discovered Sleep() and it''s running quite nicely now. What I was doing was using send()/recv()''s in a loop, but with ioctlsocket() to set non-blocking mode without understanding what it does (except that it causes recv() to return with an error when no data was waiting). So I guess using select() is the "proper" way to check for data then? What was non-blocking mode actually doing?
0

Share this post


Link to post
Share on other sites
When a socket is created, it is by default ''blocking''. This means a call to send() will not return until all the data has been sent. recv() will not return until data is recieved. This means that NO other processing occures in your program. Non-blocking sockets will return immediatly, regardless of how much data is sent or recieved. The return values of these functions are the number of bytes that were processed.

- genovov
0

Share this post


Link to post
Share on other sites
To clarify genovov''s post, blocking calls only block the thread they are running in. They won''t necessarily shut down all processing in your program, if you are running multiple threads.

select statements essentially perform signalling when a socket is ready to be read from or written to.

For the standard select statement, you pass it a structure containing the sockets you want to check on, and flags that say what kind of activity you care about. After the call, select will only return once something interesting has happened, and will set flags in structures you direct to it letting you know what kind of interesting things happened. Like there''s data waiting on socket 4, for example.

In winsock, there''s WSAAsyncSelect. This fires a windows message when something interesting happens to a socket you tell it to care about. You specify the window message that''s fired, just make sure it''s not currently used. Someone I know once made the mistake of passing WM_DESTROY to WSAAsyncSelect, so his program would happily shutdown whenever data was waiting for him. The window message parameters tell you what kind of interesting things happened and which socket they happened on.

Also in winsock2 there WSAEventSelect, which is a lot like WSAAsyncSelect, except that instead of firing a windows message, it signals on a Event object. WSAEventSelect is the prefered method of calling select in multithreaded apps.
0

Share this post


Link to post
Share on other sites