forked from len0rd/rockbox
Use cookies for thread identification instead of pointers directly which gives a buffer against wrongly identifying a thread when the slot is recycled (which has been nagging me for awhile). A slot gets 255 uses before it repeats. Everything gets incompatible so a full update is required.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19377 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
40ff47c7ee
commit
8cfbd3604f
32 changed files with 329 additions and 234 deletions
|
|
@ -71,7 +71,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef ATA_DRIVER_CLOSE
|
||||
static struct thread_entry *ata_thread_p = NULL;
|
||||
static unsigned int ata_thread_id = 0;
|
||||
#endif
|
||||
|
||||
#if defined(MAX_PHYS_SECTOR_SIZE) && MEM == 64
|
||||
|
|
@ -94,7 +94,8 @@ static void ata_lock_init(struct ata_lock *l)
|
|||
|
||||
static void ata_lock_lock(struct ata_lock *l)
|
||||
{
|
||||
struct thread_entry * const current = thread_get_current();
|
||||
struct thread_entry * const current =
|
||||
thread_id_entry(THREAD_ID_CURRENT);
|
||||
|
||||
if (current == l->thread)
|
||||
{
|
||||
|
|
@ -1350,7 +1351,7 @@ int ata_init(void)
|
|||
|
||||
last_disk_activity = current_tick;
|
||||
#ifdef ATA_DRIVER_CLOSE
|
||||
ata_thread_p =
|
||||
ata_thread_id =
|
||||
#endif
|
||||
create_thread(ata_thread, ata_stack,
|
||||
sizeof(ata_stack), 0, ata_thread_name
|
||||
|
|
@ -1370,15 +1371,15 @@ int ata_init(void)
|
|||
#ifdef ATA_DRIVER_CLOSE
|
||||
void ata_close(void)
|
||||
{
|
||||
struct thread_entry *thread = ata_thread_p;
|
||||
unsigned int thread_id = ata_thread_id;
|
||||
|
||||
if (thread == NULL)
|
||||
if (thread_id == 0)
|
||||
return;
|
||||
|
||||
ata_thread_p = NULL;
|
||||
ata_thread_id = 0;
|
||||
|
||||
queue_post(&ata_queue, Q_CLOSE, 0);
|
||||
thread_wait(thread);
|
||||
thread_wait(thread_id);
|
||||
}
|
||||
#endif /* ATA_DRIVER_CLOSE */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue