Commit 7ee6ae52 authored by scott's avatar scott
Browse files

Reduced the aggressiveness of the tile preswapper.

parent 28f61dfd
Sat Jul 11 19:57:28 1998 Scott Goehring <scott@poverty.bloomington.in.us>
* app/tile.c: Added some more debugging code.
* app/tile_cache.c (tile_idle_thread): Modified tile preswapper to
be a bit less aggressive.
Sun Jul 12 00:44:57 MEST 1998 Sven Neumann <sven@gimp.org>
* app/session.c: disabled setting the size of the dialogs since
......
......@@ -255,44 +255,59 @@ tile_idle_thread (void *data)
while(1)
{
if (!dirty_list.first) sleep(1);
if (!dirty_list.first) {
CACHE_LOCK;
while (cur_cache_dirty < max_cache_size - cur_cache_size) {
CACHE_UNLOCK;
pthread_mutex_lock(&dirty_mutex);
pthread_cond_wait(&dirty_signal,&dirty_mutex);
pthread_mutex_unlock(&dirty_mutex);
CACHE_LOCK;
}
if ((tile = dirty_list.first))
{
CACHE_UNLOCK;
TILE_MUTEX_LOCK (tile);
CACHE_LOCK;
list = tile->listhead;
if (list == &dirty_list) cur_cache_dirty -= tile_size (tile);
if (tile->next)
tile->next->prev = tile->prev;
else
list->last = tile->prev;
if (tile->prev)
tile->prev->next = tile->next;
else
list->first = tile->next;
tile->next = NULL;
tile->prev = clean_list.last;
tile->listhead = &clean_list;
if (clean_list.last) clean_list.last->next = tile;
else clean_list.first = tile;
clean_list.last = tile;
CACHE_UNLOCK;
if (tile->dirty)
{
list = tile->listhead;
if (list == &dirty_list) cur_cache_dirty -= tile_size (tile);
if (tile->next)
tile->next->prev = tile->prev;
else
list->last = tile->prev;
if (tile->prev)
tile->prev->next = tile->next;
else
list->first = tile->next;
tile->next = NULL;
tile->prev = clean_list.last;
tile->listhead = &clean_list;
if (clean_list.last) clean_list.last->next = tile;
else clean_list.first = tile;
clean_list.last = tile;
CACHE_UNLOCK;
tile_swap_out(tile);
}
else
{
CACHE_UNLOCK;
}
tile_swap_out(tile);
TILE_MUTEX_UNLOCK (tile);
}
else
{
CACHE_UNLOCK;
}
}
}
......
......@@ -35,6 +35,7 @@
static void tile_destroy (Tile *tile);
int tile_count = 0;
void
tile_init (Tile *tile,
......@@ -58,6 +59,7 @@ tile_init (Tile *tile,
{
pthread_mutex_init(&tile->mutex, NULL);
}
tile_count++;
#endif
}
......@@ -183,6 +185,7 @@ tile_destroy (Tile *tile)
TILE_MUTEX_UNLOCK (tile);
g_free (tile);
tile_count --;
}
......
......@@ -35,6 +35,7 @@
static void tile_destroy (Tile *tile);
int tile_count = 0;
void
tile_init (Tile *tile,
......@@ -58,6 +59,7 @@ tile_init (Tile *tile,
{
pthread_mutex_init(&tile->mutex, NULL);
}
tile_count++;
#endif
}
......@@ -183,6 +185,7 @@ tile_destroy (Tile *tile)
TILE_MUTEX_UNLOCK (tile);
g_free (tile);
tile_count --;
}
......
......@@ -255,44 +255,59 @@ tile_idle_thread (void *data)
while(1)
{
if (!dirty_list.first) sleep(1);
if (!dirty_list.first) {
CACHE_LOCK;
while (cur_cache_dirty < max_cache_size - cur_cache_size) {
CACHE_UNLOCK;
pthread_mutex_lock(&dirty_mutex);
pthread_cond_wait(&dirty_signal,&dirty_mutex);
pthread_mutex_unlock(&dirty_mutex);
CACHE_LOCK;
}
if ((tile = dirty_list.first))
{
CACHE_UNLOCK;
TILE_MUTEX_LOCK (tile);
CACHE_LOCK;
list = tile->listhead;
if (list == &dirty_list) cur_cache_dirty -= tile_size (tile);
if (tile->next)
tile->next->prev = tile->prev;
else
list->last = tile->prev;
if (tile->prev)
tile->prev->next = tile->next;
else
list->first = tile->next;
tile->next = NULL;
tile->prev = clean_list.last;
tile->listhead = &clean_list;
if (clean_list.last) clean_list.last->next = tile;
else clean_list.first = tile;
clean_list.last = tile;
CACHE_UNLOCK;
if (tile->dirty)
{
list = tile->listhead;
if (list == &dirty_list) cur_cache_dirty -= tile_size (tile);
if (tile->next)
tile->next->prev = tile->prev;
else
list->last = tile->prev;
if (tile->prev)
tile->prev->next = tile->next;
else
list->first = tile->next;
tile->next = NULL;
tile->prev = clean_list.last;
tile->listhead = &clean_list;
if (clean_list.last) clean_list.last->next = tile;
else clean_list.first = tile;
clean_list.last = tile;
CACHE_UNLOCK;
tile_swap_out(tile);
}
else
{
CACHE_UNLOCK;
}
tile_swap_out(tile);
TILE_MUTEX_UNLOCK (tile);
}
else
{
CACHE_UNLOCK;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment