Page 1 of 1
negative used blocks with vmware in demo 11
Posted: Tue Oct 06, 2009 8:21 am
by vijaymohan
Re: negative used blocks with vmware in demo 11
Posted: Tue Oct 06, 2009 8:54 pm
by oib111
I think the problem may be in display.c, change:
Code: Select all
case 'i': {
c = va_arg (args, int);
char str[32]={0};
itoa_s (c, 10, str);
Puts (str);
i++; // go to next character
break;
}
to
Code: Select all
case 'i': {
c = va_arg (args, int);
char str[32]={0};
itoa (c, 10, str);
Puts (str);
i++; // go to next character
break;
}
Re: negative used blocks with vmware in demo 11
Posted: Wed Oct 07, 2009 6:04 am
by vijaymohan
Thanks for the reply.
Changing itos_s to itos will print a large integer value. In my case c = va_arg (args, int); is already a negative value.

Re: negative used blocks with vmware in demo 11
Posted: Fri Oct 09, 2009 6:58 am
by Andyhhp
the problem is because you are using unsigned integers, but are using a signed conversion routine.
Because of twos complients, if the hightest bit is set, it either means its (effectivly) negative for a signed number, or is just another bit for an unsigned integer.
The conversion routines need to take this into account, so you need 2 different conversion routines.
~Andrew
Re: negative used blocks with vmware in demo 11
Posted: Fri Oct 09, 2009 4:25 pm
by vijaymohan
Hey Andy,
My problem here is the initialized memory is less than the sum of available memories of the regions. That is the reason why i am getting negative used blocks. my question is, is this the problem specific to vmware or bug in my code.
Re: negative used blocks with vmware in demo 11
Posted: Sat Oct 10, 2009 9:00 am
by Andyhhp
I guess I misunderstood your problem?
How are you calculating the "initialized memory" ?
From the memory map (which you still have a bug printing the last 4 entries - refer to my previous post to help), you will be able to use all of each avaliable memory region.
Therefore, i would probably say that that is a bug in your code
~Andrew
Re: negative used blocks with vmware in demo 11
Posted: Tue Oct 13, 2009 6:41 am
by vijaymohan
hi andy, i searched you're previous posts for help on this issue, i did't find one. could you please point me to the link or explain how to correct the problem.
Re: negative used blocks with vmware in demo 11
Posted: Thu Oct 15, 2009 5:21 pm
by vijaymohan
any help guys ? i am stuck at this.
Re: negative used blocks with vmware in demo 11
Posted: Wed Nov 04, 2009 2:38 pm
by djsilence
man, the problem could be in you printf. see, itoas function returns signed numbers, you may change it (or create copy of that) just for unsigned values. I had the same problem when number of blocks was negative, but solving of that problem is changing printf function and some changes in memory based function.
Daniel.
Re: negative used blocks with vmware in demo 11
Posted: Sun Nov 22, 2009 7:54 am
by pswin
djsilence wrote:man, the problem could be in you printf. see, itoas function returns signed numbers, you may change it (or create copy of that) just for unsigned values. I had the same problem when number of blocks was negative, but solving of that problem is changing printf function and some changes in memory based function.
Daniel.
problem is not in the printf function. in bochs it work correctly but not in the vmware
Re: negative used blocks with vmware in demo 11
Posted: Sat Nov 28, 2009 1:46 pm
by Mike
Hello,
That alone does not mean anything and has to do with hardware portability (that is, if it works on one machine but runs differently on another). Seeing how it is based off of a chapter, please test the memory management chapter in VMWare and post the results here - it might be a portability bug with VMWare. djsilence is correct here - the issue can actually be a number of things.
Your software shares alot of code from the series. Please keep in mind that, while the code in the demo can be used, it is only meant for demonstration purposes and was never designed to be used in production software.
Re: negative used blocks with vmware in demo 11
Posted: Fri Dec 04, 2009 11:20 am
by pswin
i found problem:
vmware return wrong amount of memory, it's always 2MB less than real memory, for ex:
64MB --> returned 62MB