Reduced the aggressiveness of the tile preswapper.

This commit is contained in:
scott 1998-07-12 00:59:37 +00:00
parent 28f61dfd5a
commit 7ee6ae529c
5 changed files with 90 additions and 48 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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 (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;
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;
CACHE_UNLOCK;
tile->next = NULL;
tile->prev = clean_list.last;
tile->listhead = &clean_list;
tile_swap_out(tile);
}
else
{
CACHE_UNLOCK;
}
if (clean_list.last) clean_list.last->next = tile;
else clean_list.first = tile;
clean_list.last = tile;
CACHE_UNLOCK;
tile_swap_out(tile);
TILE_MUTEX_UNLOCK (tile);
}
else
{
CACHE_UNLOCK;
}
}
}

View File

@ -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 --;
}

View File

@ -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 --;
}

View File

@ -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 (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;
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;
CACHE_UNLOCK;
tile->next = NULL;
tile->prev = clean_list.last;
tile->listhead = &clean_list;
tile_swap_out(tile);
}
else
{
CACHE_UNLOCK;
}
if (clean_list.last) clean_list.last->next = tile;
else clean_list.first = tile;
clean_list.last = tile;
CACHE_UNLOCK;
tile_swap_out(tile);
TILE_MUTEX_UNLOCK (tile);
}
else
{
CACHE_UNLOCK;
}
}
}