Re: [Algorithms] Threading by software emulation
Brought to you by:
vexxed72
From: Oscar F. <os...@tr...> - 2008-05-20 15:26:42
|
Well i think the problem is that most of us who know will have signed NDAs ... If you have access to a PS2 proper than play about with some threading and check how it works. It really is pretty simple :) Though, admittedly, it'd be far easier to work out with something like the SN Debugger to help you along ... 2008/5/20 Sebastian Lucas <del...@gm...>: > Thanks to all guys! > I think then maybe mixing the things together and by doing some hacks I > would let it work. > > I've written some demos with my ps2 (using the ps2link) using threads but > it's different when you really want to write an emulator... remember that > this is just to boost my knowledge. > > I'd really appreciated the replies =) > > Regards, > > 2008/5/19 Oscar Forth <os...@tr...>: > > Its not that crazy ... its ... well .. different. But its a very simple >> system :) >> 2008/5/19 Osman, Brian <BO...@vv...>: >> >> … I'm sure that many of the people reading this thread are thinking the >>> same thing, so I'll be the one to say it. The PS2's threading model is >>> absolutely insane (compared to any modern OS). The upside of this is that >>> it's probably easier to implement a scheduler that does what the PS2 OS >>> does. The downside is that if you don't know what the PS2 does, and you go >>> read an OS textbook, you're going to end up implementing a *real* thread >>> scheduler. And lots of PS2 software is unlikely to work correctly, because >>> it almost certainly includes lots of hacks and workarounds for the crazy >>> threading model. Good luck. >>> >>> >>> >>> -Brian >>> >>> >>> ------------------------------ >>> >>> *From:* gda...@li... [mailto: >>> gda...@li...] *On Behalf Of *David >>> Neubelt >>> *Sent:* Monday, May 19, 2008 1:29 PM >>> >>> *To:* Game Development Algorithms >>> *Subject:* Re: [Algorithms] Threading by software emulation >>> >>> >>> >>> Hey, >>> >>> >>> >>> I remember back from school in my operating systems theory class we had >>> to learn and implement different threading models. The book we were using is >>> an operating systems book with the dinosaurs on the front 'Operating System >>> Concepts'. It's the standard OS teaching book. If there is a local college >>> in your area I'm sure you could check it out from their library. >>> >>> >>> >>> That should have everything you need to know on the subject. >>> >>> >>> >>> -= Dave >>> >>> >>> ------------------------------ >>> >>> *From:* Sebastian Lucas [mailto:del...@gm...] >>> *Sent:* Sunday, May 18, 2008 7:38 PM >>> *To:* Game Development Algorithms >>> *Subject:* Re: [Algorithms] Threading by software emulation >>> >>> >>> >>> Hi Anders, >>> >>> Thanks for the reply! =) >>> I never wrote something like this before too and your suggestion sound >>> really good. >>> I'll try it! >>> >>> Thanks again for the reply, I didn't mind if this question would be Ok >>> for this list, sorry for the other users if I bother them. =) >>> >>> Regards, >>> >>> On Sun, May 18, 2008 at 4:01 PM, Anders Nilsson < >>> ja...@an...> wrote: >>> >>> Well threads is just one more thing to emulate. Say your standard >>> emulation code is like this >>> >>> State state; // this could by registers, ports etc... emulation state >>> Operations ops; // instruction pointer >>> >>> while (!ops.empty()) { >>> op=ops.next(); >>> emulate(op, ops, state); // might be a jump so needs the ops-object as >>> well >>> } >>> >>> Say this is your emulator. Now when threading comes into the picture >>> you have to emulate several threads at the same time. >>> >>> On a modern computer there is some kind of manager that decides when >>> to switch threads. When a switch occur some state is replaced and >>> exchanged for a thread-specific-state. This probably means registers >>> but perhaps not state of vga-port etc. Now you have to figure out how >>> many operations you have to run for each thread. >>> >>> SharedState ss; >>> PrivateState ps[numThreads]; // One per thread >>> Operations ops[numThreads]; // One per thread >>> >>> while (true) { // needs some kind of termination... >>> >>> threadID, numOps=scheduler.next(); // next thread to process, >>> restart when it comes to the end >>> >>> for (i=1..numOps) { >>> if (ops[threadID].empty()) { >>> scheduler.killThread(threadID); >>> break; >>> } >>> >>> op=ops[threadID].next(); >>> emulate(op, ops[threadID], ss, ps[threadID]); >>> } >>> } >>> >>> Something like that! Now how many ops per thread and time slice >>> depends on a lot on hardware dependant factors as well as thread >>> properties (perhaps each thread has a priority etc). >>> >>> A note: if there are many different processors then perhaps you need a >>> special shared state per processor, especially if they have different >>> shared resources (such as video memory or so). Another problem then >>> comes in if the thread scheduler can move threads from one processor >>> to another or not. >>> >>> I've never written anything like this and this is but a guess, but >>> hopefully it gives an idea! >>> >>> Good luck! >>> >>> /Anders Nilsson >>> >>> >>> On Sun, May 18, 2008 at 3:33 AM, Sebastian Lucas <del...@gm...> >>> wrote: >>> > Hi guys, >>> > >>> > I'm working in a ps2 emulator for educational purposes only. >>> > I could run some demos but when the demos tried to create a thread it >>> all >>> > hangs out... that's because I didn't write any thread module xD >>> > >>> > So, how can I emulate threads without making them natives? I mean, the >>> > theory behind. >>> > Maybe this is not a big deal for you guys but I'm really stuck. >>> > >>> > Regards, >>> > >>> > -- >>> > │││││ >>> > Sebastian Javier Lucas >>> > Programmer & Guitar Hero >>> > working@: gameloft >>> >>> > >>> ------------------------------------------------------------------------- >>> > This SF.net email is sponsored by: Microsoft >>> > Defy all challenges. Microsoft(R) Visual Studio 2008. >>> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>> > _______________________________________________ >>> > GDAlgorithms-list mailing list >>> > GDA...@li... >>> > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list >>> > Archives: >>> > >>> http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list >>> > >>> ------------------------------------------------------------------------- >>> This SF.net email is sponsored by: Microsoft >>> Defy all challenges. Microsoft(R) Visual Studio 2008. >>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>> _______________________________________________ >>> GDAlgorithms-list mailing list >>> GDA...@li... >>> https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list >>> Archives: >>> http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list >>> >>> >>> >>> >>> -- >>> │││││ >>> Sebastian Javier Lucas >>> Programmer & Guitar Hero >>> working@: gameloft >>> >>> ------------------------------------------------------------------------- >>> This SF.net email is sponsored by: Microsoft >>> Defy all challenges. Microsoft(R) Visual Studio 2008. >>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>> _______________________________________________ >>> GDAlgorithms-list mailing list >>> GDA...@li... >>> https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list >>> Archives: >>> http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list >>> >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2008. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> GDAlgorithms-list mailing list >> GDA...@li... >> https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list >> Archives: >> http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list >> > > > > -- > │││││ > Sebastian Javier Lucas > Programmer & Guitar Hero > working@: gameloft > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > GDAlgorithms-list mailing list > GDA...@li... > https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_name=gdalgorithms-list > |