Opened 15 years ago
Closed 13 years ago
#114 closed enhancement (fixed)
memory reservation feature needed
Reported by: | pippijn | Owned by: | Jakub Jermář |
---|---|---|---|
Priority: | major | Milestone: | 0.5.0 |
Component: | helenos/kernel/generic | Version: | mainline |
Keywords: | allocation, malloc, memory, suggestion | Cc: | martin@…, jakub@… |
Blocker for: | Depends on: | ||
See also: |
Description
The following code works:
main(){ while (malloc (1024 * 1024)); }
but the next code does not:
main(){ while (memset (malloc (1024 * 1024), 0, 1024 * 1024)); }
The full test code I was using is attached.
Attachments (1)
Change History (10)
by , 15 years ago
Attachment: | malloc_test.c added |
---|
comment:1 by , 15 years ago
And what should be the expected behaviour? In the first example you might be allocating 1 MB chunks (actually the kernel just commits the memory to you), but since you never touch most of the memory, the memory won't be actually assigned to you.
In the second example you actually force the kernel to assign the physical memory to you (in the page fault handler which gets triggered once you touch the memory using memset()). The physical memory runs out and your task gets blocked in the kernel, waiting for any physical memory to be released (by other tasks or possibly the kernel itself).
There has been some discussion recently how to allow the user to modify this kernel behaviour with respect to memory overcommit and deferred blocking in the page fault handler (see the long thread in our mailing list: http://lists.modry.cz/cgi-bin/private/helenos-devel/2009-August/005717.html).
BTW: Isn't there still an unrelated bug in your second code? When the malloc() returns NULL, you should not pass this NULL to memset(). Or am I missing something?
comment:2 by , 15 years ago
Cc: | added |
---|
comment:3 by , 15 years ago
Cc: | added |
---|
comment:4 by , 15 years ago
Summary: | memory allocation seems to be broken → memory reservation feature needed |
---|---|
Type: | defect → enhancement |
I am changing the synopsis and the type of this ticket as this is definitely not a bug, but a call for implementing memory reservations.
comment:5 by , 15 years ago
Milestone: | 0.4.2 → 0.5.0 |
---|
comment:6 by , 15 years ago
Keywords: | suggestion added |
---|
comment:7 by , 14 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:8 by , 14 years ago
Milestone: | 0.4.3 → 0.5.0 |
---|
comment:9 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed in changeset:mainline,926.
Please log bugs against the implementation or suggestions on how to further improve it as separate ticket.
malloc+memset test