Descriptor describes a memory segment

Assignment Help Basic Computer Science
Reference no: EM13935857

following online course first:
• C Tutorial

Further information about C is available here:

• C and C++ in 5 days
• https://www2.its.strath.ac.uk/courses/c/
In this exercise, we simulate a memory allocation (we just want to see the effect of fragmentation and of compacting memory fragments into larger ones). For this, we manage a list of memory segments in our program:

typedef struct segment {
int start ;
int size ;
int status ;
struct segment * next ;
} segment_t ;
The above segment descriptor describes a memory segment in terms of its start address, its size and whether it is ALLOCATED or FREE. This descriptor is part of a list (contains a pointer to next segment descriptor). Initially, there is only one segment with status == FREE, describing the complete memory as one segment.

Two functions have to be implemented: mem_alloc() and mem_free(). With mem_alloc(), a junk of memory is allocated: it takes as a parameter the size of memory required and returns a pointer to the segment created or NULL, if not enough free memory can be found. With mem_free(), a segment can be freed up again. If there are two free segments adjacent to each other, they have to be combined into one segmengmentation and of compacting memory fragments into larger ones). For this, we manage a list of memory segments in our program:
typedef struct segment {
int start ;
int size ;
int status ;
struct segment * next ;
} segment_t ;
The above segment descriptor describes a memory segment in terms of its start address, its size and whether it is ALLOCATED or FREE. This descriptor is part of a list (contains a pointer to next segment descriptor). Initially, there is only one segment with
status == FREE, describing the complete memory as one segment.

Two functions have to be implemented: mem_alloc() and mem_free(). With mem_alloc(), a junk of memory is allocated: it takes as a parameter the size of memory required and returns a pointer to the segment created or NULL, if not enough free memory can be found. With mem_free(), a segment can be freed up again. If there are two free segments adjacent to each other, they have to be combined into one segment (one of the segment nodes has to be removed from the list).

The prototype for mem_alloc(): segment_t * mem_alloc( int size ) A pointer to the allocated segment is returned.
The prototype for mem_free(): void mem_free ( segment_t * segment ) It takes the segment to be freed as a parameter.
Over time, the memory will become fragmented and a call to mem_alloc() will fail, as no segment large enough may be available. Thefunction mem_alloc() therefore has to initiate a compaction of free memory : all allocated segments should be moved towards the top of the list and all free segments to the bottom of the list. When all free segments

Reference no: EM13935857

Questions Cloud

Describe a statistical test for the ife : Describe a statistical test for the IFE. Would the IFE be more likely to hold between the United Kingdom and Hungary if trade barriers were completely removed.
Choose one exceptional world leader living or dead : Choose one exceptional world leader living or dead, good or bad, past or present. Leaders may be Presidents, Prime Ministers, Inspirational, Religious, Courageous, Artistic, Scientific, Brave, Movie Stars, CEO's, Managers, Athletes but they don't ..
Given the churn data for training and test : Given the churn data for training and test, develop models using different techniques i.e. "Logistic Regression", "Decision Trees", "Random Forests" and "Neural Networks".
Why is the synthesis of mrna a central issue for all viruses : How can several proteins be made from the above nucleic acid (ie you only saw 1 long piece). What does this imply about the activity of at least one of the proteins that are synthesized?
Descriptor describes a memory segment : The above segment descriptor describes a memory segment in terms of its start address, its size and whether it is ALLOCATED or FREE. This descriptor is part of a list (contains a pointer to next segment descriptor). Initially, there is only one se..
Leadership styles in management : Research the many leadership styles in management. Select one style and write a report that describes the positive and negative attributes of the leadership style and how you identify with it.
How can you prevent or slow down the spread : Describe 1-2 of the things that people do (you can include individuals, doctors, health care professionals, hospitals, farmers, etc.) that contribute to this problem? Why?
Calculate estimated break-even point in annual unit sales : Martinez Company has decided to introduce a new product. The new product can be manufactured by either a capital-intensive method or a labor-intensive method. Calculate the estimated break-even point in annual unit sales of the new product if Marti..
Compare the most appropriate hedge to an unhedged strategy : Then, compare the most appropriate hedge to an unhedged strategy, and decide whether Black Rod should hedge its payables position.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  How the algorithm from class for checking

Show step-by-step how the string 0001010001 would be compressed by the SEQUITUR algorithm.

  Computer crimes directions

Computer Crimes Directions: Using the internet, research a specific case of a computer crime where a person was prosecuted for committing a computer crime. Write an essay about this crime. Your essay should include the following:Explain the computer ..

  Convert the unsigned decimal to the indicated base

Convert the unsigned decimal to the indicated base: 34.50 to octal 37.150 to hexadecimal 73.5 to binary

  Explaining topic important for network administrators

Why is the topic important for network administrators today?

  Pipelined machine versus the single cycle machine

What is the speedup of the pipelined machine versus the single cycle machine assuming there are no stalls?What is the speedup of the pipelined machine versus the single cycle machine if the pipeline stalls 1 cycle for 30% of the instructions?

  Determine the best/most efficient algorithm to program

You are the owner of a new business idea called the Roomba!!! You are trying to determine the best/most efficient algorithm to program for your Roomba operation. You want the Roomba to not only clean the entire floor, but in the fastest time possible..

  Can you explain what is throw try and catch

Can you explain what is throw, try and catch

  Which areas are similar to those covered in the nist

Visit the U.S. Postal Service web site https://about.usps.com/handbooks/as805.pdf. Review the content page for this extensive manual. Compare this program to the (National Institute of Standard Technology) . Which areas are similar to those covered i..

  History about the internet

Write 3 paragraph on the history about the internet, how it was developed , when wast it made etc

  The decryption algorithm

Using RSA, encode the word "cat" by encrypting each letter separately. Choose p=3, q=11 and e=9. Apply then the decryption algorithm. Show all the calculation steps.

  Preferred storage method for vsphere

For this discussion, select your preferred storage method for vSphere and explain why this is your preferred method.•Is one storage method easier to configure and support than another? If so, which one do you feel is easier? Explain what separates th..

  Which part of the try-catch statement must be witten

Mark the following statements are True or False. If a statement is False, explain why? a. There can be only one catch-lause for each try-catch statement. b. A catch-lause is an exception handler. c. A throw statement must be located within a try-c..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd