summaryrefslogtreecommitdiffstats
path: root/uisimulator/common
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-12-03 15:33:12 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-12-03 15:33:12 +0000
commit6a05883239e3fa0569ce7ac90910c6ae8f3675c2 (patch)
tree30348ebb501bdc74dff40f3951dd4fae7770f846 /uisimulator/common
parenta4d19b7e899a9223433fcb91627af737a638e9d3 (diff)
downloadrockbox-6a05883239e3fa0569ce7ac90910c6ae8f3675c2.tar.gz
rockbox-6a05883239e3fa0569ce7ac90910c6ae8f3675c2.tar.bz2
rockbox-6a05883239e3fa0569ce7ac90910c6ae8f3675c2.zip
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
Diffstat (limited to 'uisimulator/common')
-rw-r--r--uisimulator/common/io.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 62d869f3fc..822a43b63d 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -189,6 +189,8 @@ static unsigned int rockbox2sim(int opt)
#endif
/** Simulator I/O engine routines **/
+#define IO_YIELD_THRESHOLD 512
+
enum
{
IO_READ,
@@ -198,11 +200,12 @@ enum
struct sim_io
{
struct mutex sim_mutex; /* Rockbox mutex */
- volatile int cmd; /* The command to perform */
- volatile int ready; /* I/O ready flag - 1= ready */
- volatile int fd; /* The file to read/write */
- void* volatile buf; /* The buffer to read/write */
- volatile size_t count; /* Number of bytes to read/write */
+ int cmd; /* The command to perform */
+ int ready; /* I/O ready flag - 1= ready */
+ int fd; /* The file to read/write */
+ void *buf; /* The buffer to read/write */
+ size_t count; /* Number of bytes to read/write */
+ size_t accum; /* Acculated bytes transferred */
};
static struct sim_io io;
@@ -211,16 +214,22 @@ int ata_init(void)
{
/* Initialize the rockbox kernel objects on a rockbox thread */
mutex_init(&io.sim_mutex);
+ io.accum = 0;
return 1;
}
static ssize_t io_trigger_and_wait(int cmd)
{
- void *mythread;
+ void *mythread = NULL;
ssize_t result;
- /* Allow other rockbox threads to run */
- mythread = thread_sdl_thread_unlock();
+ if (io.count > IO_YIELD_THRESHOLD ||
+ (io.accum += io.count) >= IO_YIELD_THRESHOLD)
+ {
+ /* Allow other rockbox threads to run */
+ io.accum = 0;
+ mythread = thread_sdl_thread_unlock();
+ }
switch (cmd)
{
@@ -233,7 +242,10 @@ static ssize_t io_trigger_and_wait(int cmd)
}
/* Regain our status as current */
- thread_sdl_thread_lock(mythread);
+ if (mythread != NULL)
+ {
+ thread_sdl_thread_lock(mythread);
+ }
return result;
}