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

  Write a method, insertat, that takes four parameters

write a method, insertAt, that takes four parameters:an array of integers; the length of the array; an integer, say insertItem; and an interger, say, index.

  The current environment

The current environment doesn't have wireless interface, and the management would like to procure a cutting edge wireless technology infrastructure for the organisation.

  Process for information systems management for organization

Describe the process for Information Systems Management for any organization using clear example.

  Set the character variable r=0

Write a small program that will set the character variable R=0

  Evaluation methods that could be utilized to ensure quality

Provide details about evaluation methods that could be utilized to ensure quality

  Overload the operator >> and the operator << for a class

Self-test exercise 17 asked you to overload the operator >> and the operator

  Many types of formal management plans

There are many types of formal management plans (scope, schedule, communication, etc.,) that should be created in order to complete a project on time and within budget. Consider the group project that you worked on for this class and choose on..

  Calculate and display the volume of a cylinder

Write a complete program for Visual C++ to calculate and display the volume of a cylinder, given its radius and height. Your program must meet the following requirements.

  Describe binary tree traversals

Describe binary tree traversals (inorder, postorder, preorder and level-order). Give examples of applications of these traversals.

  Current network design

Imagine that you are the administrator for a small accounting company, which currently employees 200 people. The CEO announces a merger that would double the number employees to 400. Your current network design is as follows:   Current network ..

  What is the meaning of digital forensics theory

- What is the meaning of digital forensics theory and its intended application during the digital forensics investigation?

  Determine the expected number of empty bins

Assume that n balls are tossed into n bins, where each toss is independent and ball is equally likely to end up in any bin. Determine the expected number of empty bins?

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