new:kzalloc

This commit is contained in:
fslongjin
2022-08-15 17:57:05 +08:00
parent cec44c1fd7
commit f513286f53
11 changed files with 73 additions and 29 deletions

View File

@ -37,14 +37,14 @@ void mutex_lock(mutex_t *lock)
spin_lock(&lock->wait_lock);
if (likely(mutex_is_locked(lock)))
{
struct mutex_waiter_t *waiter = (struct mutex_waiter_t *)kmalloc(sizeof(struct mutex_waiter_t), 0);
struct mutex_waiter_t *waiter = (struct mutex_waiter_t *)kzalloc(sizeof(struct mutex_waiter_t), 0);
if (waiter == NULL)
{
kerror("In mutex_lock: no memory to alloc waiter. Program's behaviour might be indetermined!");
spin_unlock(&lock->wait_lock);
return;
}
memset(waiter, 0, sizeof(struct mutex_waiter_t));
// memset(waiter, 0, sizeof(struct mutex_waiter_t));
waiter->pcb = current_pcb;
list_init(&waiter->list);
list_append(&lock->wait_list, &waiter->list);