⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tonadolmemshow.txt

📁 Tonadol下memShow源码
💻 TXT
字号:
STATUS memPartShow
(
    PART_ID partId,				/* partition ID */
    int type					/* 0 = statistics, 1 = statistics & list */
)
    
{
    intnumBlocks;
    unsignedtotalBytes = 0;
    unsignedbiggestWords = 0;

    if (partId == NULL)
    {
	printf ("No partId specified.\n");
	return (ERROR);
    }

    if (ID_IS_SHARED (partId))  /* partition is shared? */
    {
	if (smMemPartShowRtn == NULL)
	{
	    errno = S_smObjLib_NOT_INITIALIZED;
	    return (ERROR);
	}
        return ((STATUS) (*smMemPartShowRtn)(SM_OBJ_ID_TO_ADRS (partId), type));
    }

    /* partition is local */

    if (OBJ_VERIFY (partId, memPartClassId) != OK)
	return (ERROR);

    /* print out list header if we are going to print list */

    if (type == 1)
    {
	printf ("\nFREE LIST:\n");
	printf ("   num    addr       size\n");
	printf ("  ---- ---------- ----------\n");
    }

    semTake (&partId->sem, WAIT_FOREVER);

    if ((totalBytes = memPartAvailable (partId, &biggestWords, type)) == ERROR)
    {
	semGive (&partId->sem);
        return (ERROR);
    }
    else
        biggestWords /= 2;/* memPartAvailable returns bytes, not words */
    
    if (type == 1)
	printf ("\n\n");

    numBlocks = dllCount (&partId->freeList);

    if (type == 1)
	printf ("SUMMARY:\n");
    printf (" status    bytes     blocks   avg block  max block\n");
    printf (" ------ ---------- --------- ---------- ----------\n");
    printf ("current\n");

    if (numBlocks != 0)
	printf (" free %10u %9u %10u %10u\n", totalBytes, numBlocks,
			totalBytes / numBlocks, 2 * biggestWords);
    else
	printf ("   no free blocks\n");

    if (partId->curBlocksAllocated != 0)
	printf ("  alloc %10u %9u %10u  -\n",
			2 * partId->curWordsAllocated, partId->curBlocksAllocated,
        		(2 * partId->curWordsAllocated) / partId->curBlocksAllocated);
    else
	printf ("   no allocated blocks\n");

    printf ("cumulative\n");

    if (partId->cumBlocksAllocated != 0)
	printf ("  alloc %10u %9u %10u -\n",
			2 * partId->cumWordsAllocated, partId->cumBlocksAllocated,
			(2 * partId->cumWordsAllocated) / partId->cumBlocksAllocated);
    else
	printf ("   no allocated blocks\n");

    semGive (&partId->sem);

    return (OK);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -