📄 test_random.c
字号:
/*************************************************************************** random_test.c - Shows the randomness of the random-module ------------------- begin : 2002 authors : Linus Gasser emails : linus.gasser@epfl.ch ***************************************************************************//*************************************************************************** Changes ------- date - name - description 02-09-20 - ineiti- begin 02-10-22 - daniela - test uniformity of random generator 02-11-04 - ineiti - extended for replacement for msg-qs 04/03/03 - ineiti - added a small description **************************************************************************//*************************************************************************** * * * 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. * * * ***************************************************************************/char desc[] ="Description:\n""This test is to show the randomness of the random-module. First,\n""10000 random-numbers are counted, and 256*the probatility of each\n""one is printed. Then, a small sample of 8-bit random numbers are\n""outputted.\n\n";#include "system.h"#include "cdb.h"#include "sdb.h"#include "std.h"#include "debugging.h"#include "chain.h"#define DBG_LVL 4struct chain_t *test;void *start_it( void *arg ) { swr_sdb_id random, sink; int value; test = swr_chain_create( NEW_SPC_VAR( "random", random ), NEW_SPC_VAR( "sink", sink ), CHAIN_END ); // Do something value = 123456; swr_sdb_set_config_int( sink, "size", 1234567 ); swr_sdb_set_config_int( sink, "flag", 2 ); PR( "Sending request to show randomness\n" ); swr_sdb_send_msg( random, SUBS_MSG_USER, NULL, -1 ); swr_sdb_set_config_int( sink, "size", 123 ); swr_sdb_set_config_int( sink, "flag", 3 ); PR( "Sending a request to display the randoms...\n" ); swr_sdb_send_msg( random, SUBS_MSG_USER, NULL, -1 ); PR( "Waiting to finish\n" ); usleep( 1000000 ); return 0;}struct thread start;/** * This function is called upon "insmod" and is used to register the * different parts of the module to the SPM. */int um_module_init(void) { PR_CL( desc ); if ( swr_thread_init( &start, start_it, NULL ) < 0 ) goto first_no_stack; return 0;first_no_stack: PR_DBG( 0, "Couldn't allocate stack\n" ); return -1;}void um_module_exit( void ) { swr_thread_free( &start, NULL ); swr_chain_destroy( test );}module_init( um_module_init );module_exit( um_module_exit );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -