/* * misc.c * Description: * PCD miscellaneous functions implementation file * * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ * * This application is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * version 2.1, as published by the Free Software Foundation. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /* Author: * Hai Shalom, hai@rt-embedded.com * * PCD Homepage: http://www.rt-embedded.com/pcd/ * PCD Project at SourceForge: http://sourceforge.net/projects/pcd/ * */ /**************************************************************************/ /* INCLUDES */ /**************************************************************************/ #include #include #include #include #include #include #include "system_types.h" #include "pcdapi.h" #include "pcd.h" static pid_t netRxPid = 0; static Uint32 netRxPriority = 0; STATUS PCD_misc_reduce_net_rx_priority( Int32 priority ) { struct sched_param setParam; netRxPid = PCD_api_find_process_id( "softirq-net-rx/" ); if ( netRxPid ) { /* Get net rx priority */ if ( sched_getparam( netRxPid, &setParam ) == 0 ) { netRxPriority = setParam.sched_priority; } else { /* Default value */ netRxPriority = 50; } PCD_PRINTF_STDOUT( "Setting low priority for softirq-net-rx task" ); /* Setup a new low priority to enable system startup */ setParam.sched_priority = 0; sched_setscheduler( netRxPid, SCHED_OTHER, &setParam ); setpriority( PRIO_PROCESS, netRxPid, priority ); return STATUS_OK; } return STATUS_NOK; } STATUS PCD_misc_restore_net_rx_priority( void ) { struct sched_param setParam; if ( netRxPid ) { PCD_PRINTF_STDOUT( "Restoring priority for softirq-net-rx task" ); /* Restore priority */ setParam.sched_priority = netRxPriority; sched_setscheduler( netRxPid, SCHED_FIFO, &setParam ); netRxPid = 0; } return STATUS_OK; }