Releasing a Noncontiguous Memory Area

The vfree( ) function releases noncontiguous memory areas. Its parameter addr contains the initial linear address of the area to be released. vfree( ) first scans the list pointed to by vmlist to find the address of the area descriptor associated with the area to be released:

write lock(&vmlist lock);

for (p = &vmlist ; (tmp = *p) ; p = &tmp->next) { if (tmp->addr == addr) { *p = tmp->next;

vmfree area pages((unsigned long)(tmp->addr), tmp->size);

write unlock(&vmlist lock);

kfree(tmp);

return;

write unlock(&vmlist lock);

printk("Trying to vfree( ) nonexistent vm area (%p)\n", addr);

Was this article helpful?

0 0

Post a comment