Jump to content
IGNORED

Atari 800 % CPU Utilization Question


atx4us

Recommended Posts

It's always 100% - 6502 has no halt/wait facility.

 

In an emulation scenario, you could detect idle time to a reasonable degree, like key input waits in E:/K:, waits within SIO routines etc.

 

Different story for apps/games though - every program would be different, and a tight loop that executes several or a dozen instructions might be considered idle time, or might be doing something productive.

Link to comment
Share on other sites

Also, it's common for programmers to implement an indicator for their own development purposes. For example, changing the color of the background as different routines are executed gives you a general idea of how much CPU time is used as long as everything is synced to the screen. But as Gary said, there's no way to really know what someone else's program is doing without disassembling or tracing it and finding all the wasted cycles.

 

I suppose a complex analytical emulator could be created to attempt to quantify how much time is spent in loops waiting for something to happen as opposed to other code that actively moves data around.

Edited by Bryan
Link to comment
Share on other sites

It's always 100% - 6502 has no halt/wait facility.

What about for DRAM refresh and video DMA?

What he means is, 100% of the available cycles are always used doing something on the A8 (and on most 8-bit systems) because software cannot stop the CPU with a halt or sleep function. On CPU's that have such a function, it's common to do the work that needs doing then put the CPU to sleep until a timer or other event wakes it up for the next update (often done for power savings). In that case it's easy to show how much CPU time went unused if you can monitor when the CPU is active.

Link to comment
Share on other sites

What he means is, 100% of the available cycles are always used doing something on the A8 (and on most 8-bit systems) because software cannot stop the CPU with a halt or sleep function. On CPU's that have such a function, it's common to do the work that needs doing then put the CPU to sleep until a timer or other event wakes it up for the next update (often done for power savings). In that case it's easy to show how much CPU time went unused if you can monitor when the CPU is active.

Power savings with such mechanisms would be virtually nil until CMOS chips were in use... NMOS idles at almost the same load as at 100% utilization.

Edited by kool kitty89
Link to comment
Share on other sites

Power savings with such mechanisms would be virtually nil until CMOS chips were in use... NMOS idles at almost the same load as at 100% utilization.

 

Well right, much of the power is consumed driving against capacitance when things switch states, but these NMOS designs must have a clock at all times or they will forget their current state.

 

Anyway, the OP was asking about CPU utilization on real hardware and it's not like the PC or some other multitasking system where applications are given a portion of the CPU's time according to a scheduler process, or like systems with an idle or sleep function, where the program can choose not to use the CPU 100% of the time. On the Atari, only the programmer knows if the code being run is useful or just wasting time until the next VBLANK or keypress or whatever. So, there's no easy way to gauge "left-over" CPU time since the OS has no multitasking features.

 

If there were an OS routine that a program could jump to to count cycles every time the program finished a state update then you could get an idea of how much time different programs really spent doing things, but what would you do with the extra time other than just knowing what it was?

Link to comment
Share on other sites

Ok, i think its clear now that it is not possible to transport the idea of "idle time" from a modern OS to the A8.

But the idea with cycle counting in a busy-waitloop is interesting. Although just for informational purpose and in no way useful.

When a program runs in one VBI, my main-loop looks kinda like this:

 

endless: jmp endless

 

 

So I can change that into

 

endless:
    clc
    lda $f0
    adc #1
    sta $f0
    lda $f1
    adc #0
    sta $f1
    lda $f2
    ...
    ...

    jmp endless

 

and stop the program after a known period of time (a fixed count of VBIs, maybe) to check the value in the emulators monitor.

However, in my current game, the calculation of the AI is done in the mainloop. And as it hasn't a constant run-time the above method wouldn't be accurate.

What I do sometimes is just check VCOUNT at the end of my VBI and substract it from the max value. So I get at least a 2-scan-line accurate reading.

 

Any other ideas?

Link to comment
Share on other sites

VCOUNT + RTCLOK will do the trick for longer durations, as long as you properly check for the update race. That's how the OS measures the baud rate at the beginning of each block on tape.

 

I usually use a sampling profiler to tell how much time a program is spending in interrupts, especially DLIs.

Link to comment
Share on other sites

Hi,

 

I once wrote a simple debugger that steals away CPU cycles from the (main) programm by having a configurable idle loop in the VBI. This was used to make programs slower so that I was able to investigate their operations. This were programs that would not work on an Emulator, because it used hardware that is not emulated.

 

The source and disk image can be found at

http://wiki.strotmann.de/wiki/Wiki.jsp?page=A%20simple%206502%20debugger

Link to comment
Share on other sites

Hi,

 

I once wrote a simple debugger that steals away CPU cycles from the (main) programm by having a configurable idle loop in the VBI. This was used to make programs slower so that I was able to investigate their operations. This were programs that would not work on an Emulator, because it used hardware that is not emulated.

 

The source and disk image can be found at

http://wiki.strotmann.de/wiki/Wiki.jsp?page=A%20simple%206502%20debugger

 

There are a few A8 emulators out there. Do you know for sure that none of the emulators have this hardware emulated?

Link to comment
Share on other sites

There are a few A8 emulators out there. Do you know for sure that none of the emulators have this hardware emulated?

 

Yes, 100% sure, as it was very exotic hardware (ARGS RS232 Cart, etc)

 

There is quite a lot of hardware that is not emulated:

 

* Speedy 1050

* Happy 810/1050

* several Flash cards

* USB Cart

....

 

 

-- Carsten

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...