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

📄 ramdemo.c

📁 嵌入式操作系统Nucleus Plus中使用的文件系统
💻 C
📖 第 1 页 / 共 5 页
字号:
            /*  Get it. */
            c = (char) getch();

            /*  See what the user wants to do.  */
            switch (c)
            {
                /*  User wants to either start or stop a task.  */
                case '0':
                case '1':
                case '2':

                    /* Toggle tasks on / off */
                    i = (int) (c - '0');
                    if (task_is_running[TASK0+i])
                    {
                        /* Flag the task off. It will stop itself next time
                           it calls looping(). (We don't want to stop a task 
                           when it owns a resource) */
                        task_is_running[TASK0+i] = NO;
                    }
                    else
                    {
                        NU_Resume_Task(NUIP_PLUS_To_RTX[TASK0+i]);
                        task_is_running[TASK0+i] = YES;
                    }

                    /* In case they disabled all tasks, we want to stay in
                       the loop.  This way they can resume */
                    stay_in = YES;

                    /*  Check and see if they disabled all of them.  */
                    for (i = TASK0; i < HIGHEST_TASK; i++)
                    {
                        if (task_is_running[i])
                            stay_in = NO;
                    }
                    break;

                case 'x':
                case 'X':

                    /*  Many new systems do not have an exit capability.  If
                        your system does, place the exit code here.  */
                    DOS_Exit(0);
                    break;

                default:
                    break;
            }
        }
    } while (stay_in);

#endif

#if (USE_PUTS)

	/* use a counter to just run through 10 times, then "stop" */
	if (gPutsCounter >= 10)
	{
		/* stay in a loop for a debugger to break on */
	 	while (1)
	 	{
	 		i = i;
	 	}
	}	

#endif

    /*  Restore the preemption status that the caller initiated with. */
    NU_Change_Preemption(preempt_status);

    return(YES);
}

/************************************************************************/
/*                                                                      */
/*  FUNCTION                           "error_log"                      */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This routine processes a non-fatal error.                       */
/*                                                                      */
/*  AUTHOR                                                              */
/*                      Accelerated Technology                          */
/*  CALLED FROM                                                         */
/*                                                                      */
/*      most functions in demo                                          */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      NONE                                                            */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      error_no                            Number of error being       */
/*                                          reported.                   */
/*                                                                      */
/*  OUTPUTS                                                             */
/*       NONE                                                           */
/*                                                                      */
/************************************************************************/
int error_log(int error_no)
{
    /*  Validate the error number.  */
    if (RAM_Errors_Index > 9)
        RAM_Errors_Index = 0;

    /*  Store the error.  */
    RAM_Errors[RAM_Errors_Index] = error_no;

    return(error_no);
}

/************************************************************************/
/*                                                                      */
/*  FUNCTION                           "display task"                   */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This routine is responsible for displaying the results of the   */
/*      demonstration program.  It may not be used in your system.      */
/*      If you do not have printf, it may be a good idea to set a       */
/*      breakpoint in this routine to see the results.                  */
/*                                                                      */
/*  AUTHOR                                                              */
/*                      Accelerated Technology                          */
/*  CALLED FROM                                                         */
/*                                                                      */
/*      kernel                        This is a task started by         */
/*                                    nuf_task_0                        */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      [printf]                      Prints a string to the stdout.    */
/*                                                                      */
/*  INPUTS                                                              */
/*                                                                      */
/*      error_no                            Number of error being       */
/*                                          reported.                   */
/*                                                                      */
/*  OUTPUTS                                                             */
/*       NONE                                                           */
/*                                                                      */
/************************************************************************/
void display_task(void)
{
#if (USE_PUTS)
	char            msgStr[60];
#endif
	long	task0DirectoriesScanned;
	long	task0FilesScanned;

	long	task1FilesCreated;
	long	task1FilesRenamed;
	long	task1FilesDeleted;

	long	task2FilesCreated;
	long	task2FilesRenamed;
	long	task2FilesDeleted;
	
	// For ports without print capability, these locals can be examined after
	// breaking...

  while (NU_TRUE)
  {
	task0DirectoriesScanned = RAM_Directories_Scanned[0];
	task0FilesScanned = RAM_Files_Scanned[0];

	task1FilesCreated = RAM_Files_Created[1];
	task1FilesRenamed = RAM_Files_Renamed[1];
	task1FilesDeleted = RAM_Files_Deleted[1];

	task2FilesCreated = RAM_Files_Created[2];
	task2FilesRenamed = RAM_Files_Renamed[2];
	task2FilesDeleted = RAM_Files_Deleted[2];
	
	
//    while (NU_TRUE)
//    {
#if (PRINT_OUT)
        printf("******************************************************\n\r");
        printf("Press 0, 1, 2 to deactivate/activate task or X to exit\n\r");
        printf("******************************************************\n\r");
        printf("\n\r");
        printf("Task 0 Statistics:\n\r");
        printf("    Directories Scanned: %d\n\r", task0DirectoriesScanned);
        printf("    Files Scanned:       %d\n\r", task0FilesScanned);
        printf("\n\r");
        printf("Task 1 Statistics:\n\r");
        printf("    Files Created:       %d\n\r", task1FilesCreated);
        printf("    Files Renamed:       %d\n\r", task1FilesRenamed);
        printf("    Files Deleted:       %d\n\r", task1FilesDeleted);
        printf("\n\r");
        printf("Task 2 Statistics:\n\r");
        printf("    Files Created:       %d\n\r", task2FilesCreated);
        printf("    Files Renamed:       %d\n\r", task2FilesRenamed);
        printf("    Files Deleted:       %d\n\r", task2FilesDeleted);
        printf("\n\r");
        printf("\n\r");
        printf("\n\r");
        printf("\n\r");
        printf("\n\r");


#endif


#if (USE_PUTS)
 		cls();
        puts("******************************************************\n");
        puts("Press 0, 1, 2 to deactivate/activate task or X to exit\n");
        puts("******************************************************\n");
        puts("\n");
        puts("Task 0 Statistics:\n");

        puts("    Directories Scanned: ");
		itoa(RAM_Directories_Scanned[0], msgStr, 10);
		puts(msgStr);
        puts("\n");
        
        puts("    Files Scanned:       ");
 		itoa(RAM_Files_Scanned[0], msgStr, 10);
		puts(msgStr);
        puts("\n");
        
        puts("\n");
        puts("Task 1 Statistics:\n");
        puts("    Files Created:       " );
   		itoa(RAM_Files_Created[1], msgStr, 10);
		puts(msgStr);
        puts("\n");

        puts("    Files Renamed:       " );
   		itoa(RAM_Files_Renamed[1], msgStr, 10);
		puts(msgStr);
        puts("\n");

        puts("    Files Deleted:       " );
   		itoa(RAM_Files_Deleted[1], msgStr, 10);
		puts(msgStr);
        puts("\n");

        puts("\n");
        puts("Task 2 Statistics:\n");
        puts("    Files Created:       ");
        itoa(RAM_Files_Created[2], msgStr, 10);
		puts(msgStr);
        puts("\n");

        puts("    Files Renamed:       " );
        itoa(RAM_Files_Renamed[2], msgStr, 10);
		puts(msgStr);
        puts("\n");

        puts("    Files Deleted:       " );
        itoa(RAM_Files_Deleted[2], msgStr, 10);
		puts(msgStr);
        puts("\n");

        puts("\n");
        puts("\n");
        puts("\n");
        puts("\n");
        puts("\n");
		

        /* increment our 10x counter for the stop above */
       	gPutsCounter = gPutsCounter + 1;

#endif


        /*  Sleep for a while.   This is currently 3 seconds with a 10ms
            tick.*/
        NU_Sleep(30);
    }
}  /* end of display_task  */

⌨️ 快捷键说明

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