Team/image stuff now uses lists instead of kqueues.
The kernel_daemon now utilizes the updated list API. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2567 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
878c4156af
commit
429578fb0b
@ -49,7 +49,7 @@ register_image(team_id teamID, image_info *_info, size_t size)
|
||||
team = team_get_team_struct_locked(teamID);
|
||||
if (team) {
|
||||
image->info.id = id;
|
||||
insque(image, &team->image_queue);
|
||||
list_add_item(&team->image_list, image);
|
||||
}
|
||||
|
||||
RELEASE_TEAM_LOCK();
|
||||
@ -67,7 +67,6 @@ status_t
|
||||
unregister_image(team_id teamID, image_id id)
|
||||
{
|
||||
status_t status = B_ENTRY_NOT_FOUND;
|
||||
struct image *image;
|
||||
struct team *team;
|
||||
cpu_status state;
|
||||
|
||||
@ -76,9 +75,11 @@ unregister_image(team_id teamID, image_id id)
|
||||
|
||||
team = team_get_team_struct_locked(teamID);
|
||||
if (team) {
|
||||
kqueue_foreach (&team->image_queue, image) {
|
||||
struct image *image = NULL;
|
||||
|
||||
while ((image = list_get_next_item(&team->image_list, image)) != NULL) {
|
||||
if (image->info.id == id) {
|
||||
remque(image);
|
||||
list_remove_link(image);
|
||||
free(image);
|
||||
status = B_OK;
|
||||
break;
|
||||
@ -100,10 +101,10 @@ unregister_image(team_id teamID, image_id id)
|
||||
int32
|
||||
count_images(struct team *team)
|
||||
{
|
||||
struct image *image;
|
||||
struct image *image = NULL;
|
||||
int32 count = 0;
|
||||
|
||||
kqueue_foreach (&team->image_queue, image) {
|
||||
|
||||
while ((image = list_get_next_item(&team->image_list, image)) != NULL) {
|
||||
count++;
|
||||
}
|
||||
|
||||
@ -119,15 +120,11 @@ count_images(struct team *team)
|
||||
status_t
|
||||
remove_images(struct team *team)
|
||||
{
|
||||
struct image *image, *nextImage;
|
||||
struct image *image;
|
||||
|
||||
ASSERT(team != NULL);
|
||||
|
||||
// can't use kqueue_foreach() because "image" gets freed
|
||||
for (image = (struct image *)team->image_queue.next;
|
||||
image != (void *)&team->image_queue; image = nextImage) {
|
||||
nextImage = image->next;
|
||||
|
||||
while ((image = list_remove_head_item(&team->image_list)) != NULL) {
|
||||
free(image);
|
||||
}
|
||||
return B_OK;
|
||||
@ -138,7 +135,6 @@ status_t
|
||||
_get_image_info(image_id id, image_info *info, size_t size)
|
||||
{
|
||||
status_t status = B_ENTRY_NOT_FOUND;
|
||||
struct image *image;
|
||||
struct team *team;
|
||||
cpu_status state;
|
||||
|
||||
@ -147,7 +143,9 @@ _get_image_info(image_id id, image_info *info, size_t size)
|
||||
|
||||
team = thread_get_current_thread()->team;
|
||||
if (team) {
|
||||
kqueue_foreach (&team->image_queue, image) {
|
||||
struct image *image = NULL;
|
||||
|
||||
while ((image = list_get_next_item(&team->image_list, image)) != NULL) {
|
||||
if (image->info.id == id) {
|
||||
memcpy(info, &image->info, size);
|
||||
status = B_OK;
|
||||
@ -167,7 +165,6 @@ status_t
|
||||
_get_next_image_info(team_id teamID, int32 *cookie, image_info *info, size_t size)
|
||||
{
|
||||
status_t status = B_ENTRY_NOT_FOUND;
|
||||
struct image *image;
|
||||
struct team *team;
|
||||
cpu_status state;
|
||||
|
||||
@ -176,8 +173,10 @@ _get_next_image_info(team_id teamID, int32 *cookie, image_info *info, size_t siz
|
||||
|
||||
team = team_get_team_struct_locked(teamID);
|
||||
if (team) {
|
||||
struct image *image = NULL;
|
||||
int32 count = 0;
|
||||
kqueue_foreach (&team->image_queue, image) {
|
||||
|
||||
while ((image = list_get_next_item(&team->image_list, image)) != NULL) {
|
||||
if (count == *cookie) {
|
||||
memcpy(info, &image->info, size);
|
||||
status = B_OK;
|
||||
|
@ -66,7 +66,7 @@ unregister_kernel_daemon(void (*function)(void *, int), void *arg)
|
||||
while ((daemon = list_get_next_item(&gDaemons, daemon)) != NULL) {
|
||||
if (daemon->function == function && daemon->arg == arg) {
|
||||
// found it!
|
||||
list_remove_link(daemon);
|
||||
list_remove_item(&gDaemons, daemon);
|
||||
free(daemon);
|
||||
break;
|
||||
}
|
||||
@ -113,7 +113,7 @@ register_kernel_daemon(void (*function)(void *, int), void *arg, int frequency)
|
||||
} else
|
||||
daemon->offset = 0;
|
||||
|
||||
list_add_link_to_tail(&gDaemons, daemon);
|
||||
list_add_item(&gDaemons, daemon);
|
||||
mutex_lock(&gDaemonMutex);
|
||||
|
||||
return B_OK;
|
||||
|
@ -356,7 +356,7 @@ create_team_struct(const char *name, bool kernel)
|
||||
team->pending_signals = 0;
|
||||
team->death_sem = -1;
|
||||
team->user_env_base = 0;
|
||||
initque(&team->image_queue);
|
||||
list_init(&team->image_list);
|
||||
|
||||
if (arch_team_init_team_struct(team, kernel) < 0)
|
||||
goto error1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user