Question

Consider an allocator on a 32-bit system that uses an implicit free list. Each memory block, eith...

Consider an allocator on a 32-bit system that uses an implicit free list. Each memory block, either allocated or free, has a size that is a multiple of four bytes. Thus, only the 30 higher order bits in the header and footer are needed to record block size, which includes the header and footer and is represented in units of bytes. The usage of the remaining 2 lower order bits is as follows: bit 0 indicates the use of the current block: 1 for allocated, 0 for free. bit 1 indicates the use of the previous adjacent block: 1 for allocated, 0 for free Below is a helper routine defined to facilitate the implementation of free (void *P). Which option, if any, will complete the routine so that it performs the function properly?

Note: "size" in the answers indicates the size of the entire block /* given a pointer to a valid block header or footer, returns the size of the block */

int size(void *hp)

{

int result;

__________;

return result;

}

options:

1.result=(*(int *)hp)&(-7)

2.result=((*(char *)hp)&(-5))<<2

3.result=(*(int *)hp)&(-3)

4.result=(*hp)&(-7)

5.None of these

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:- option 3 is right answer because the memory will be allocated and it will be in integer data type. It will release the 3 memory blocks.

Add a comment
Know the answer?
Add Answer to:
Consider an allocator on a 32-bit system that uses an implicit free list. Each memory block, eith...
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
  • Question 3: Consider a 32-bit physical address memory system with block size 16 bytes and a...

    Question 3: Consider a 32-bit physical address memory system with block size 16 bytes and a 32 blocks direct mapped cache. The cache is initially empty. The following decimal memory addresses are referenced 1020, 1006, 1022, 5106, 994, and 2019 Map the addresses to cache blocks and indicate whether hit or miss. Note: You must use the hexadecimal approach in solving this question. You must also show the computations of dividing the memory address into tag bits, cache index bits,...

  • Consider a pure paging system that uses 32-bit addresses (each of which specifies one byte of...

    Consider a pure paging system that uses 32-bit addresses (each of which specifies one byte of memory), contains 2 GB of main memory, and has a page size (ps) of 8 KB. 1. Given 32-bits for each PTE, how many total bytes of memory are required to store the page table?

  • Really don't know what its about... Course in operating system, file system Question 2. File Systems (10 marks) (a) Consider a 32GB hard disk and a FAT file system with 24 bits cluster (block) ad...

    Really don't know what its about... Course in operating system, file system Question 2. File Systems (10 marks) (a) Consider a 32GB hard disk and a FAT file system with 24 bits cluster (block) address. What is the minimum block (cluster) size in order to fully utilize all space in the hard disk? (3 marks) (b) Consider an index-based file system with the inode containing 64 direct pointers, 1 indirect pointer, and 1 double-indirect pointer. Suppose the size of a...

  • Assume you have: 32-bit addresses, 4KB Page size, 4MB Physical Memory Space, 4KB Cache with 4-way...

    Assume you have: 32-bit addresses, 4KB Page size, 4MB Physical Memory Space, 4KB Cache with 4-way set associative and LRU replacement, 32 Byte Cache block size, 4-entry fully associative TLB. A program to be run on this machine begins as follows:   double A[1024]; int i, j; double sum = 0; for( i = 0; i < 1024; i++ )       // first loop      A[i] = i; for( j = 0; j < 1024; j += 16 )   // second loop     ...

  • Need this in C The starter code is long, if you know how to do it...

    Need this in C The starter code is long, if you know how to do it in other way please do. Do the best you can please. Here's the starter code: // ----------------------------------------------------------------------- // monsterdb.c // ----------------------------------------------------------------------- #include #include #include // ----------------------------------------------------------------------- // Some defines #define NAME_MAX 64 #define BUFFER_MAX 256 // ----------------------------------------------------------------------- // Structs typedef struct { char name[NAME_MAX]; int hp; int attackPower; int armor; } Character; typedef struct { int size; Character *list; } CharacterContainer; // ----------------------------------------------------------------------- //...

  • I've posted 3 classes after the instruction that were given at start You will implement and...

    I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...

  • Problem 3 (List Implementation) (35 points): Write a method in the DoublyLList class that deletes the...

    Problem 3 (List Implementation) (35 points): Write a method in the DoublyLList class that deletes the first item containing a given value from a doubly linked list. The header of the method is as follows: public boolean removeValue(T aValue) where T is the general type of the objects in the list and the methods returns true if such an item is found and deleted. Include testing of the method in a main method of the DoublyLList class. ------------------------------------------------------------------------------------- /** A...

  • How to write the insert, search, and remove functions for this hash table program? I'm stuck......

    How to write the insert, search, and remove functions for this hash table program? I'm stuck... This program is written in C++ Hash Tables Hash Table Header File Copy and paste the following code into a header file named HashTable.h Please do not alter this file in any way or you may not receive credit for this lab For this lab, you will implement each of the hash table functions whose prototypes are in HashTable.h. Write these functions in a...

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
ADVERTISEMENT