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

📄 test_second.c

📁 This a framework to test new ideas in transmission technology. Actual development is a LDPC-coder in
💻 C
字号:
/***************************************************************************              second.c  -  RTLinux kernel module for a second chain!!                            -------------------    begin                :  2002    authors              :  Linus Gasser    emails               :  linus.gasser@epfl.ch ***************************************************************************//***************************************************************************                                 Changes                                 ------- date - name - description 02-09-20 - ineiti- begin 04/03/03 - ineiti - changed for new 'copy'-module and 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""The second working chain!!! Historical reasons ;) Just a source,\n""a copy-module and two sinks. Should output twice each test-phrase.\n\n";#include "spc.h"#include "std.h"#define DBG_LVL 4pthread_mutex_t mutex_here;struct chain_t *second, *third;void *start_it( void *arg ) {  swr_spc_id_t source, sink, sink2, copy;  int str_id;  char str_str[128];  PR_DBG( 0, "Getting subsystem cdb-ids\n" );  second = swr_chain_create( NEW_SPC_VAR( "source", source ),                             NEW_SPC_VAR( "copy", copy ),                             NEW_SPC_VAR( "sink", sink ),			     CHAIN_END );  third = swr_chain_create( OLD_SPC_OUT( copy, 1 ),		            NEW_SPC_VAR( "sink", sink2 ),			    CHAIN_END );  swr_sdb_set_config_int( sink, "flag", 1 );  swr_sdb_set_config_int( sink, "size", 128 );  swr_sdb_set_config_int( sink2, "flag", 1 );  swr_sdb_set_config_int( sink2, "size", 128 );  PR_DBG( 0, "Sending request...\n" );  swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 );  str_id = swr_sdb_get_config_parameter_nbr( source, "source_str" );  if ( str_id < 0 ) {    PR_DBG( 0, "Couldn't get id of str\n" );  } else {    usleep( 200000 );    PR_DBG( 0, "Changing config %i\n", source );    strncpy( str_str, "Hello world!!!!", 128 );    if ( swr_sdb_set_config_parameter_value( source, str_id, str_str ) < 0 ) {      PR_DBG( 0, "Couldn't set the new string\n" );    }    swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 );    usleep( 200000 );    PR_DBG( 0, "Changing config %i\n", source );    strncpy( str_str, "Yes, finally it works", 128 );    if ( swr_sdb_set_config_parameter_value( source, str_id, str_str ) < 0 ) {      PR_DBG( 0, "Couldn't set the new string\n" );    }    swr_sdb_send_msg( source, SUBS_MSG_USER, NULL, -1 );  }  usleep( 200000 );  return 0;}swr_spc_id_t cdb_id;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 second_no_thread;  }  return 0;second_no_thread:  PR_DBG( 0, "Couldn't allocate stack\n" );  return -1;}void um_module_exit( void ) {  swr_thread_free( &start, NULL );  swr_chain_destroy( third );  swr_chain_destroy( second );}module_init( um_module_init );module_exit( um_module_exit );

⌨️ 快捷键说明

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