The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to Find JRE installed in linux machine..? XivaX Shell Programming and Scripting 3 01-31-2008 06:18 PM
find usable keyboard and mouse for UNIX spac machine. Help duke0001 UNIX for Dummies Questions & Answers 2 09-05-2006 02:12 PM
How to find which machine ... premnathk UNIX for Dummies Questions & Answers 3 07-17-2006 05:40 AM
ping Port number of HPUX machine Teh Tiack Ein HP-UX 1 12-04-2005 12:38 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-21-2006
Registered User
 

Join Date: Sep 2006
Posts: 19
trying to find number of caches on a machine

I am trying to find the number of caches on a machine programatically.

#include <stdio.h>
#include <malloc.h>

int main(void)
{
int *ptr,*ptr1,i,j;
j=0;
i=1;
printf("Changing allocation with brk()\n");
while(1)
{

for(j=0;j<i;j++)
{
ptr = (int *) malloc(i);
ptr[j] = j;
printf("VALUE %d is:: %lu\n",j,ptr[j]);
brk(ptr+i);
ptr1=(ptr+j);
printf(" VALUE of trace end is::%lu\n",ptr1);
i++;
}
}
return 0;
}

I was thinking of embedding time in such a way that I could track access to a particular growing memory size. The moment the access time varied, the cache level was changed. Am I thinking along the right lines, please guide me.
Reply With Quote
Forum Sponsor
  #2  
Old 10-30-2006
Registered User
 

Join Date: Feb 2005
Posts: 53
Interesting idea but your code seems to be too complicated for me.
Try to alloc memory once (e.g. 10MB)
and perform timing of 'mangling' areas of growing size:
256kB, 512kB, and so on.
Mangling can be as simple as mem[i]++

Regards
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0