test_8.c

来自「MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis」· C语言 代码 · 共 126 行

C
126
字号
/*  This file is part of MANTIS OS, Operating System for Nymph.  See http://mantis.cs.colorado.edu/  Copyright (C) 2003 University of Colorado, Boulder  This program is free software; you can redistribute it and/or  modify it under the terms of the GNU General Public License  as published by the Free Software Foundation; either version 2  of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  (See http://www.gnu.org/copyleft/gpl.html)  along with this program; if not, write to the Free Software  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,  USA, or send email to mantis-users@cs.colorado.edu.*/#include "mos.h"#ifdef PLATFORM_LINUX#include <unistd.h>#include <stdio.h>#include <stdlib.h>#else#include "printf.h"#endif#include "msched.h"#include "arith-code.h"#include "clock.h"#include "command_daemon.h"thread_t *current_thread;uint8_t quit_flag = 0;#define BUF_SIZE 130static uint8_t in_buf[BUF_SIZE], out_buf[BUF_SIZE];void compress_thread (void){   int16_t i;   uint32_t *time_elapsed;   printf ("starting compress %p %p\n", in_buf, out_buf);      for (i = 0; i < BUF_SIZE - 2; i++) {      in_buf[i] = i % 8;   }   //in_buf[i - 1] = EOF;   for (i = 0; i < BUF_SIZE; i++) {      printf ("i[%d]: i: %d o: %d\n", i, in_buf[i], out_buf[i]);   }      //real_timer_clear();   arith_code_encode (in_buf, sizeof (in_buf), out_buf, sizeof (out_buf));   //time_elapsed = real_timer_get_ticks();#ifdef ARCH_AVR   printf ("done compressing, time: %l\n", *time_elapsed);#else   printf ("done compressing, time: %uld\n", *time_elapsed);#endif   for (i = 0; i < BUF_SIZE; i++) {      printf ("i[%d]: i: %d o: %d\n", i, in_buf[i], out_buf[i]);   }   quit_flag = 1;}void decompress_thread (void){   int16_t i;   uint32_t *time_elapsed;   printf ("starting decompress\n");   for (i = 0; i < BUF_SIZE; i++) {      in_buf[i] = 16;   }   for (i = 0; i < BUF_SIZE; i++) {      printf ("i[%d]: i: %d o: %d\n", i, in_buf[i], out_buf[i]);   }   //real_timer_clear();   arith_code_decode (out_buf, sizeof (out_buf), in_buf, sizeof (in_buf));   //time_elapsed = real_timer_get_ticks();#ifdef ARCH_AVR   printf ("done decompressing, time: %l\n", *time_elapsed);#else   printf ("done decompressing, time: %uld\n", *time_elapsed);#endif   for (i = 0; i < BUF_SIZE; i++) {      printf ("i[%d]: i: %d o: %d\n", i, in_buf[i], out_buf[i]);   }   quit_flag = 1;}static void test_arith_code(void){   compress_thread();   decompress_thread();   mos_thread_resume(current_thread);}  static void test_arith_code_func(void){   mos_thread_new(test_arith_code, 128, PRIORITY_NORMAL);   current_thread = mos_thread_current();   mos_thread_suspend();   mos_thread_sleep(10);   mos_thread_new (mos_command_daemon, 196, PRIORITY_NORMAL); } void start (void){   mos_thread_new (test_arith_code_func, 64, PRIORITY_NORMAL);}

⌨️ 快捷键说明

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