Skip to content

Basic sample code demonstrating how to use the hardware spinlock as a mutex between the Sony PSP (Playtation Portable) main CPU and the Media Engine CPU, enabling concurrent writing in cached memory.

License

Notifications You must be signed in to change notification settings

mcidclan/me-spinlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Me/Sc Spinlock Sample

A demonstration of a custom mutex implementation using a hardware spinlock for synchronizing shared memory access between the main CPU and the Media Engine.

Features

  • Independent counters: Each processor maintains its own counter.
  • Shared memory: Two shared counters are accessible by both processors.
  • Spinlock synchronization: Custom hardware mutex implementation to prevent race conditions.

How it works

The spinlock uses a hardware register (0xbc100048) in which:

  • Main CPU can only modify bit[0].
  • Media Engine can only modify bit[1].
  • Exclusive access is guaranteed through custom XOR logic.

Without the spinlock, concurrent access to shared memory would create race conditions.

build

make clean; make;

Special Thanks

This sample code wouldn't have been possible without the resources from uofw on GitHub and the PSP homebrew community, which served as valuable sources of knowledge. Thanks especially to crazyc from ps2dev.org, without whom the use of the Media Engine in the community would be far more difficult. Thanks to all developers and contributors who have kept the scene alive and to those who continue to do so.

Other indispensable resources:

m-c/d

About

Basic sample code demonstrating how to use the hardware spinlock as a mutex between the Sony PSP (Playtation Portable) main CPU and the Media Engine CPU, enabling concurrent writing in cached memory.

Topics

Resources

License

Stars

Watchers

Forks