unknownbrackets / ps2autotests

A set of test programs run on a PS2, with accompanying results.
ISC License
25 stars 7 forks source link

Added DeleteThread test for ee kernel. #9

Closed jpd002 closed 9 years ago

jpd002 commented 9 years ago

Small test for EE's kernel DeleteThread function.

unknownbrackets commented 9 years ago

Rather than "high" and "low", I think it's better to say "better" and "worse", since the values are inversed (high integers are actually low priority.)

It might be interesting to see if it's possible to delete a suspended thread or other states.

I know one tricky thing we still haven't nailed down on the PSP is that deletion doesn't happen "immediately" - it seems to happen on an interval. Before that the thread is only ended.

Also, deleting a thread twice could provide an interesting result.

-[Unknown]

jpd002 commented 9 years ago

Thanks for the input, I'll make the changes to the test.

How did you find out that thread deletion wasn't immediate on the PSP? I don't think the PS2 has that kind of behavior, but we never know.

unknownbrackets commented 9 years ago

Actually, I was mistaken. It's the threadend event that's delayed, I think. Maybe termination also, but not deletion actually.

So, I created a bunch of threads that just sleep and never wake up.

Then I created another set of threads that each waited for the first set of threads to wake up (there's a syscall to wait for a thread to end.) Each records the current nanosecond count after it receives the termination.

After that, terminate each thread and record the current nanosecond count for each.

When all threads have terminated, log the differences between the nanosecond counts. A thread terminated at 2us doesn't trigger a threadend until 1995us (and in between this, other things are happening.) It might just be there's a severe delay, or that threadend notification happens at the worst priority or something.

Still need to do more testing on that, but the game I thought depended on that behavior ended up not to be after all.

-[Unknown]

jpd002 commented 9 years ago

Oh wow, that's a really strange delay, good thing the game didn't rely on that.

jpd002 commented 9 years ago

I've added tests for DeleteThread on all possible states for threads. I've also added a test for DeleteThread on an already deleted thread.

I think that should cover most of the cases where that function can be used.