Simulate the effects of sector caching a bit. Bypass I/O yield if a byte counter hasn't reached a certain threshold. Can be dialed-in by changing a #define.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15871 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2007-12-03 15:33:12 +00:00
parent a4d19b7e89
commit 6a05883239

View file

@ -189,6 +189,8 @@ static unsigned int rockbox2sim(int opt)
#endif #endif
/** Simulator I/O engine routines **/ /** Simulator I/O engine routines **/
#define IO_YIELD_THRESHOLD 512
enum enum
{ {
IO_READ, IO_READ,
@ -198,11 +200,12 @@ enum
struct sim_io struct sim_io
{ {
struct mutex sim_mutex; /* Rockbox mutex */ struct mutex sim_mutex; /* Rockbox mutex */
volatile int cmd; /* The command to perform */ int cmd; /* The command to perform */
volatile int ready; /* I/O ready flag - 1= ready */ int ready; /* I/O ready flag - 1= ready */
volatile int fd; /* The file to read/write */ int fd; /* The file to read/write */
void* volatile buf; /* The buffer to read/write */ void *buf; /* The buffer to read/write */
volatile size_t count; /* Number of bytes to read/write */ size_t count; /* Number of bytes to read/write */
size_t accum; /* Acculated bytes transferred */
}; };
static struct sim_io io; static struct sim_io io;
@ -211,16 +214,22 @@ int ata_init(void)
{ {
/* Initialize the rockbox kernel objects on a rockbox thread */ /* Initialize the rockbox kernel objects on a rockbox thread */
mutex_init(&io.sim_mutex); mutex_init(&io.sim_mutex);
io.accum = 0;
return 1; return 1;
} }
static ssize_t io_trigger_and_wait(int cmd) static ssize_t io_trigger_and_wait(int cmd)
{ {
void *mythread; void *mythread = NULL;
ssize_t result; ssize_t result;
if (io.count > IO_YIELD_THRESHOLD ||
(io.accum += io.count) >= IO_YIELD_THRESHOLD)
{
/* Allow other rockbox threads to run */ /* Allow other rockbox threads to run */
io.accum = 0;
mythread = thread_sdl_thread_unlock(); mythread = thread_sdl_thread_unlock();
}
switch (cmd) switch (cmd)
{ {
@ -233,7 +242,10 @@ static ssize_t io_trigger_and_wait(int cmd)
} }
/* Regain our status as current */ /* Regain our status as current */
if (mythread != NULL)
{
thread_sdl_thread_lock(mythread); thread_sdl_thread_lock(mythread);
}
return result; return result;
} }