mirror of
https://github.com/drasko/codezero.git
synced 2026-04-03 18:49:03 +02:00
Few more fixes.
Boot files and tasks are now initialised together. Theads can ask for particular space and thread ids, if they're unused. This enables us to get predefined ids for known tasks such as the VFS task. Fixes to README Other minor fixes.
This commit is contained in:
@@ -83,11 +83,29 @@ int thread_create(struct task_ids *ids)
|
||||
copy_pgd_kern_all(new->pgd);
|
||||
|
||||
/* Get new space id */
|
||||
ids->spid = id_new(space_id_pool);
|
||||
if (ids->spid == TASK_ID_INVALID) {
|
||||
ids->spid = id_new(space_id_pool);
|
||||
printk("Got new space id: %d\n", ids->spid);
|
||||
} else {
|
||||
printk("Try new space id: %d\n", ids->spid);
|
||||
if ((ids->spid = id_get(space_id_pool, ids->spid)) < 0)
|
||||
ids->spid = id_new(space_id_pool);
|
||||
else
|
||||
printk("Success.\n");
|
||||
}
|
||||
|
||||
spc_found:
|
||||
/* Get a new thread id */
|
||||
ids->tid = id_new(thread_id_pool);
|
||||
if (ids->tid == TASK_ID_INVALID) {
|
||||
ids->tid = id_new(thread_id_pool);
|
||||
printk("Got new thread id: %d\n", ids->tid);
|
||||
} else {
|
||||
printk("Try new thread id: %d\n", ids->tid);
|
||||
if ((ids->tid = id_get(thread_id_pool, ids->tid)) < 0)
|
||||
ids->tid = id_new(thread_id_pool);
|
||||
else
|
||||
printk("Success.\n");
|
||||
}
|
||||
|
||||
/* Set all ids */
|
||||
set_task_ids(new, ids);
|
||||
|
||||
@@ -250,7 +250,7 @@ void switch_to_user(struct ktcb *task)
|
||||
jump(task);
|
||||
}
|
||||
|
||||
void init_inittask(char *name, struct task_ids *ids)
|
||||
void init_pager(char *name, struct task_ids *ids)
|
||||
{
|
||||
struct svc_image *taskimg = 0;
|
||||
struct ktcb *task;
|
||||
@@ -262,7 +262,7 @@ void init_inittask(char *name, struct task_ids *ids)
|
||||
* This also solves the problem of freeing the bootstack and making use
|
||||
* of the initial kspace pgd.
|
||||
*/
|
||||
if (!strcmp(name, "mm0"))
|
||||
if (!strcmp(name, __PAGERNAME__))
|
||||
task = current; /* mm0 is the mockup current during init */
|
||||
else
|
||||
task = (struct ktcb *)zalloc_page();
|
||||
@@ -341,7 +341,7 @@ void init_tasks()
|
||||
* This must come last so that other tasks can copy its pgd before it
|
||||
* modifies it for its own specifics.
|
||||
*/
|
||||
init_inittask("mm0", &ids);
|
||||
init_pager(__PAGERNAME__, &ids);
|
||||
}
|
||||
|
||||
void start_kernel(void)
|
||||
|
||||
@@ -50,3 +50,15 @@ int check_and_clear_bit(u32 *word, int bit)
|
||||
}
|
||||
}
|
||||
|
||||
int check_and_set_bit(u32 *word, int bit)
|
||||
{
|
||||
/* Check that bit was clear */
|
||||
if (!(word[BITWISE_GETWORD(bit)] & BITWISE_GETBIT(bit))) {
|
||||
word[BITWISE_GETWORD(bit)] |= BITWISE_GETBIT(bit);
|
||||
return 0;
|
||||
} else {
|
||||
//printf("Trying to set already set bit\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,3 +33,14 @@ int id_del(struct id_pool *pool, int id)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return a specific id, if available */
|
||||
int id_get(struct id_pool *pool, int id)
|
||||
{
|
||||
int ret = check_and_set_bit(pool->bitmap, id);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
else
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user