Question

1. What are the two memory pools for programs running a modern operating system? 2. Given the following program: #includec io

please answer all 5 questions, thanks.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 1:

There are two memory pools in a modern operating system:

  • Stack
  • Heap

Answer 2:

(a)

4 bytes 0x101C a=5 main function stack frame 4 bytes b 10 0x1018 STACK

(b)

4 bytes 0x1028 func1 function stack frame 4 bytes 0x1024 4 bytes 2I0] 0x1020 4 bytes 0x101C a 5 main function stack frame 4 b

Answer 3:

Memory on heap, in C++, is allocated using new operator.

For example:-
int *p = new int; // This will allocate memory for 1 int (4 bytes) on the heap

Answer 4:

Memory on the heap, in C++, can be deallocated using delete operator.

For example:-
int *p = new int; // This will allocate memory for 1 int (4 bytes) on the heap
delete p; // This will deallocate memory for p

Answer 5:

A dynamic array is deallocated using delete[] operator.

For example:
int *p = new int[5]; // This will allocate memory for 5 ints (20 bytes) on the heap
delete[] p; // This will deallocate memory for p

FOR ANY HELP JUST DROP A COMMENT

Add a comment
Know the answer?
Add Answer to:
please answer all 5 questions, thanks. 1. What are the two memory pools for programs running...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Name: Homework #13 What are the two memory pools for programs running a modern operating system? ...

    code in C++ Name: Homework #13 What are the two memory pools for programs running a modern operating system? 1. Given the following program: 2. sincludeciostream> using nanespace std; void func1(int); int main() int a 5, b 10; func1(a): return 0; void func1(int a) int z(2]: int ys a. What is on the stack before the first function call (assume a memory starting address of ex1018)? b. What is on the stack after the function call is executed (before returning...

  • C ++ 1. Write down the missing code according to the comments. #include <cstdlib> #include <iostream>...

    C ++ 1. Write down the missing code according to the comments. #include <cstdlib> #include <iostream> using namespace std; void fun1(int radius) {     /*     dynamic memory management     */     double * dmptr;     double circumference;         /*     add the code below to:     - allocate a memory location for a double and nameless variable in heap and assign its address to the pointer     - assign 3.14 to the variable in heap via the pointer....

  • Call stack question! Long one... The call stack is part of main memory that is reserved...

    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...

  • IN JAVA: List or draw out the memory contents for BOTH of the slides below. (you do not need to s...

    IN JAVA: List or draw out the memory contents for BOTH of the slides below. (you do not need to show addresses)Clearly list out what memory is stored in each region under the bolded (Stack, Heap, or Globals). Assume the garbage collector has not yet run. Multiple Objects Stack //Multiple dynamic objects class objx f int i void print ) f system.out.println ("i-" + i)i Heap / same as before public class DynamicExample3 f public static void main (Stringl] argv)...

  • 81. The following function call doesn’t agree with its prototype:              cout << BoxVolume( 10, 5...

    81. The following function call doesn’t agree with its prototype:              cout << BoxVolume( 10, 5 );                    int BoxVolume(int length = {1}, int width = {1}, int height = {1});                                                     T__   F__                                                                     82. The following function is implemented to swap in memory the          argument-values passed to it:         void swap(int a, int b)                   {           int temp;             temp = a;             a = b;             b = temp;        ...

  • Please help with this coding 1.You need to dynamically allocate memory to read into a number...

    Please help with this coding 1.You need to dynamically allocate memory to read into a number of elements. At first, you need to determine how many numbers (here, ‘n’) to be read. Next, you need to dynamically allocate memory for ‘n’ integers. As you see,‘x’ is an integer pointer which needs to dynamically allocate memory to read ‘n’integers into it fromthekeyboard. 2 Read nintegers into the allocated block using scanf. 3. Complete the printArrayfunction to display ‘n’ integers. void printArray(int...

  • questions from my assembly book. 12 Assembly Subroutines . OBLEMS 121 122 123 When a instructio...

    questions from my assembly book. 12 Assembly Subroutines . OBLEMS 121 122 123 When a instructio Which instruction is used to call a function? struction is used to return from a function? call instruction is executed, how does the processor know how to get back to where t came from? 12.4 Which registers are used for passing arguments? 5 Which registers are used for returning results? 126 Which registers must be preserved before using? 12.7 What instructions can be used...

  • C++ Language 1. Why would you prefer to use recursion? (Multiple answers or one answer) a...

    C++ Language 1. Why would you prefer to use recursion? (Multiple answers or one answer) a When the problem to be solved is naturally recursive, a recursive algorithm provides a clear and simple solution. b Since stack memory is faster than heap memory, and recursion uses stack memory, it is preferable to use recursion. c If a language, like LISP, or a subset of a language, like C++ templates, provides recursion but does not provide looping, then use recursion. d...

  • problem 2 and 3 1. For each variable (a-g) describe whether the variable itself is global...

    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...

  • 1. Here are codes to define a stack class based on dynamic array, please complete the...

    1. Here are codes to define a stack class based on dynamic array, please complete the copy constructor //--- Definition of Stack copy constructor Stack::Stack(const Stack & original) : myCapacity(original.myCapacity), myTop(original.myTop) { //--- Get new array for copy myArray = new(nothrow) StackElement[myCapacity]; if (myArray != 0) // check if memory available                         // copy original's array member into this new array {              // Please complete the function here        } else {          cerr << "*Inadequate memory to allocate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT