mirror of
https://github.com/drasko/codezero.git
synced 2026-02-27 17:23:13 +01:00
Mutex test progress
- Mutex test added. Forked tasks demonstrate produce/consumer using a shared mmap'ed page. - Added l4lib assembler syscall - Added forgotten SWI to mutex control offset in syscall page. - Added mutex head initialization - Contended child successfully sleeps in a waitqueue. Issues: - Somehow the child's produced page buffer is altered at about [4020] offset. Parent fails to validate buffer therefore. - Need to add syncing to test so that parent does not unlock and lock again before child has a chance to lock buffer and produce.
This commit is contained in:
@@ -24,23 +24,29 @@ struct mutex_queue {
|
||||
|
||||
struct mutex_queue_head {
|
||||
struct list_head list;
|
||||
|
||||
/*
|
||||
* Lock for mutex_queue create/deletion and also list add/removal.
|
||||
* Both operations are done jointly so a single lock is enough.
|
||||
*/
|
||||
struct mutex mutex_control_mutex;
|
||||
int count;
|
||||
} mutex_queue_head;
|
||||
|
||||
/*
|
||||
* Lock for mutex_queue create/deletion and also list add/removal.
|
||||
* Both operations are done jointly so a single lock is enough.
|
||||
*/
|
||||
struct mutex mutex_control_mutex;
|
||||
|
||||
void init_mutex_queue_head(void)
|
||||
{
|
||||
memset(&mutex_queue_head, 0, sizeof (mutex_queue_head));
|
||||
INIT_LIST_HEAD(&mutex_queue_head.list);
|
||||
mutex_init(&mutex_queue_head.mutex_control_mutex);
|
||||
}
|
||||
void mutex_queue_head_lock()
|
||||
{
|
||||
mutex_lock(&mutex_control_mutex);
|
||||
mutex_lock(&mutex_queue_head.mutex_control_mutex);
|
||||
}
|
||||
|
||||
void mutex_queue_head_unlock()
|
||||
{
|
||||
mutex_unlock(&mutex_control_mutex);
|
||||
mutex_unlock(&mutex_queue_head.mutex_control_mutex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,5 +30,6 @@ BEGIN_PROC(arm_system_calls)
|
||||
swi 0x14 @ kread /* 0x28 */
|
||||
swi 0x14 @ kmem_control /* 0x2C */
|
||||
swi 0x14 @ time /* 0x30 */
|
||||
swi 0x14 @ mutex_control /* 0x34 */
|
||||
END_PROC(arm_system_calls)
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include INC_PLAT(printascii.h)
|
||||
#include INC_API(syscall.h)
|
||||
#include INC_API(kip.h)
|
||||
#include INC_API(mutex.h)
|
||||
|
||||
unsigned int kernel_mapping_end;
|
||||
|
||||
@@ -344,6 +345,7 @@ void init_tasks()
|
||||
/* Initialise the global task and address space lists */
|
||||
init_ktcb_list();
|
||||
init_address_space_list();
|
||||
init_mutex_queue_head();
|
||||
|
||||
printk("%s: Initialized. Starting %s as pager.\n",
|
||||
__KERNELNAME__, __PAGERNAME__);
|
||||
|
||||
@@ -54,7 +54,7 @@ void syscall_init()
|
||||
syscall_table[sys_kread_offset >> 2] = (syscall_fn_t)sys_kread;
|
||||
syscall_table[sys_kmem_control_offset >> 2] = (syscall_fn_t)sys_kmem_control;
|
||||
syscall_table[sys_time_offset >> 2] = (syscall_fn_t)sys_time;
|
||||
syscall_table[sys_mutex_control_offset >> 2] = (syscall_fn_t)sys_mutex_control;
|
||||
syscall_table[sys_mutex_control_offset >> 2] = (syscall_fn_t)sys_mutex_control;
|
||||
|
||||
add_mapping(virt_to_phys(&__syscall_page_start),
|
||||
ARM_SYSCALL_PAGE, PAGE_SIZE, MAP_USR_RO_FLAGS);
|
||||
|
||||
Reference in New Issue
Block a user