The address space of a process contains a stack segment, a heap segment, a .bss segment, a .data segment and a .txt segment. Where are the following stored?
a) Dynamic data allocated by malloc()
b) An initialized external static variable
c) An integer variable declared as static but not initialized within a function
Dynamic data allocated by malloc() is stored in heap segment because malloc() takes only one argument.
An initialized external static variable is present in data segment because they have an explicit initialization.
An integer variable declared as static but not initialized within a function is present in bss segment which is also known as uninitialized data segment.
The address space of a process contains a stack segment, a heap segment, a .bss segment,...
Options for both are: - .rodata - .bss - .data - heap - stack Consider the following code snippet: int arrt 8 1 int* p - arr; int val - void main(O int x; static int y; printf("end of main\n") The specific memory areas variable arr and variable p will be stored in are Select] andSelect respectively
problem 2 and 3 1. For each variable (a-g) describe whether the variable itself is global or local, static or not static, and initialized or uninitialized. (Hints: Global variables are always static. Local variables become static when declared with 'static'. For pointers, consider the pointer itself, not anything the pointer might point to.) 2. For each variable (a-g), describe where it is located when DoFunctionB is running. That is, for each variable, describe whether it is on the stack, in...
Where are intermediate values stored when a recursive function is recursing? Select one: a. system stack b. random memory c. heap d. data segment of memory
Memory Consider a process running the following program #include estdlib.h> #include #define const char* int int <stdio.h> TO PRINT toPrintCPtr "Good luck!" TO PRINT; main for (i -0; i < sizeof (TO PRINT)-1; i++) printf("%c %c\n", toPrintCPt r [1], toupper(toPrintCPt r [i])); return(EXIT SUCCESS); Please tell where the following objects are stored in memory. Your choices are a. ROM BIOS b. kernal Memory (the OS) c. shared library memory (the glibc library) d. .text segment e. .rodata segment f. .data...
Most systems allow a program to allocate more memory to its address space during execution. Allocation of data in the heap segments of programs is and example of such allocated memory. What is required to support dynamic memor allocation in the following schemes? a. Contiguous memory allocation b. Pure segmentation c. Pure paging Explain each of the above schemes and provide sources to back your answers.
Call stack question! Long one... The call stack is part of main memory that is reserved for function calling. Like all r memory it is finite, so can be exhausted resulting in a stack overflow. Recursive functions allocate space on the stack for each recursive call: if there are many such recursive calls a stack overflow can result. The questions that follow ask you to investigate recursive functions and stack overflows. Note that when running programs in the Linux terminal...
I need help with this problem.I am currenlty struggelling with it. Consider a computer system using paging, where the address space of every process has a size of C = 2c bytes and the page size is S = 2s bytes. Each entry in the page table uses E bytes. Calculate the number of pages of a process, and the size of a page table (in bytes). Assume that the space wasted by a process in main memory is defined...
In a system using paged segmentation, the logical address space of each process consists of a maximum of 16 segments, each of which can be up to 64 Kbytes in size. Physical pages are 512 bytes. Determine how many bits are needed to specify each of the quantities below, justifying each of your answers by demonstrating the calculations. a) Segment number (segment address) b) Number of a logical page within the segment c) Displacement within a page e) Complete logical...
5. (10%) Consider the following C code segment: int fun (int a, int b) { static int count; int x, *p; x= a +b; p-malloc (sizeof (int)); a) What is the lifetime of the variable count? b) What is the scope of the variable count? c) Which part of memory is the storage allocated for x? d) What is the lifetime of the variable x? e) Which part of memory is the storage allocated for the integer pointed to by...
12. Consider C++ class. Which one of the following choices is NOT correct? A. Class instances can be static, stack dynamic, or heap dynamic. B. If static or stack dynamic, they are referenced directly with value variables. C. If stack dynamic, they are referenced through pointers. D. Stack dynamic instances of classes are always created by the elaboration of an object declaration. E. The lifetime of such a class instance ends when the end of the scope of its declaration...