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