473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

i need to create C program. Any one have Code


Hello ,

I am trying to create a program

where all detail,

http://www.albany.edu/~csi333/projects.htm

in short hand. I need to create four command

a allocate at give size

d deallocate from starting, and size

s staticical of free and min, man free blocks

q quit

i need this program until 24th anyone help me out
--
Posted via http://dbforums.com
Nov 13 '05 #1
2 2851
On Fri, 19 Sep 2003 09:27:27 -0400, aj902 <me*********@dbforums.com>
wrote:

Hello ,

I am trying to create a program

where all detail,

http://www.albany.edu/~csi333/projects.htm


Nice try. However you obviously didn't read this page because
there is not enough information to complete your class assignment.

"The necessary information about dynamic memory allocation
and the best fit strategy will be presented in the lecture."

"A data structure for maintaining information about free
blocks will be discussed in class."

"You must follow the programming and documentation guidelines
indicated in a previous handout."

Nick.

Nov 13 '05 #2

"aj902" <me*********@dbforums.com> schrieb im Newsbeitrag
news:33****************@dbforums.com...

Hello ,

I am trying to create a program

where all detail,

http://www.albany.edu/~csi333/projects.htm

in short hand. I need to create four command

a allocate at give size

d deallocate from starting, and size

s staticical of free and min, man free blocks

q quit

i need this program until 24th anyone help me out


Not with the code, of course, but some hints to get you started:

You have a memory block of 10000 chars at your disposition. From this block
you allocate and deallocate smaller blocks, so after some time your original
block will consist of a mixture of free and allocated pieces...

What information do you need for each piece?
Hint: start address, size, and state(free or allocated)
You may want to put this information into a struct
struct mem_block_t
{
char *start;
size_t size;
int allocated;
};

Now, as the user of your program allocates and deallocates memory, you will
need more of these structs
You will want to make the growing and shrinking of the pool of structs
flexible and easy to handle, so a linked list comes into mind..

extend the struct to:
struct mem_block_t
{
char *start;
size_t size;
int allocated;
struct mem_block_t *next;
};

That's it.
Now all you need are functions to
create a new struct - malloc() is your friend.
insert the new struct and subtract the size of the block which it describes
from the adjacent free space (if any) or remove the struct describing the
adjacent free space if no free space is left. (of course you will also have
to modify the address contained therein)
(you insert by modifying the "next" pointers in the previous and the
new)
remove a struct and add the size of the block which it describes to the
adjacent free space (if any) (of course you will also have to modify the
address contained therein) or create a new struct which describes the
new free block if no free space was adjacent and insert it.
scan the list for free and allocated blocks for the statistics and for
finding the smallest block in which a new request fits (the requirement
that, if there are more blocks of the same size, the block with the
lowest address must be selected does not need any extra work).
and your main menu handler

Now think about how you could test your program and perform the necessary
testing.

Today is the 20th..
plenty of time left to write your code and even come back with questions if
you have problems

HTH
Robert
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

55
by: Alex | last post by:
Hello people, The following is not a troll but a serious request. I found myself in a position where I have to present a Pro/Con list to management and architects in our company with regard to...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
4
by: naknak4 | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
6
by: naknak | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
3
by: sunbeam | last post by:
Short Description of the Project: we developed a e-learning system for our students. each student has a unique username/password to view the modules he/she should view and nothing more. since we...
1
by: Tony Freixas | last post by:
Hello, I'm trying to create a wrapper for a program. I want to execute program 'X' by running program 'Y', such that 'Y' appears to function pretty much like 'X' both in the way command line...
0
by: yjh0914 | last post by:
hi guys! so im basically editting my post i made earlier as it wznt as specific.. i have to make a program that basically ranks students by their cumulative gpa. the student's info is on a csv file...
1
by: javabeginner123 | last post by:
i have a java prob, and i have to solve it fast, but i'm just getting to know it, so plz help me solve it with full code completed, thanks so much. the prob is to create a monter fight and there is...
18
by: Angus | last post by:
Hello We have a lot of C++ code. And we need to now create a library which can be used from C and C++. Given that we have a lot of C++ code using classes how can we 'hide' the fact that it is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.