\doxysection{src/vty/cpu\+\_\+sched\+\_\+vty.c File Reference}
\label{cpu__sched__vty_8c}\index{src/vty/cpu\_sched\_vty.c@{src/vty/cpu\_sched\_vty.c}}


Implementation to CPU / Threading / Scheduler properties from VTY configuration.  


{\ttfamily \#include \char`\"{}config.\+h\char`\"{}}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$limits.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$sched.\+h$>$}\newline
{\ttfamily \#include $<$ctype.\+h$>$}\newline
{\ttfamily \#include $<$sys/types.\+h$>$}\newline
{\ttfamily \#include $<$sys/stat.\+h$>$}\newline
{\ttfamily \#include $<$fcntl.\+h$>$}\newline
{\ttfamily \#include $<$dirent.\+h$>$}\newline
{\ttfamily \#include $<$pthread.\+h$>$}\newline
{\ttfamily \#include $<$inttypes.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/vty/vty.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/vty/command.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/vty/tdef\+\_\+vty.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/tdef.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/fsm.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/linuxlist.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ cpu\+\_\+affinity\+\_\+it}
\item 
struct \textbf{ sched\+\_\+vty\+\_\+opts}
\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ \+\_\+\+GNU\+\_\+\+SOURCE}
\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ sched\+\_\+vty\+\_\+thread\+\_\+id} \{ \newline
\textbf{ SCHED\+\_\+\+VTY\+\_\+\+THREAD\+\_\+\+SELF}
, \newline
\textbf{ SCHED\+\_\+\+VTY\+\_\+\+THREAD\+\_\+\+ALL}
, \newline
\textbf{ SCHED\+\_\+\+VTY\+\_\+\+THREAD\+\_\+\+ID}
, \newline
\textbf{ SCHED\+\_\+\+VTY\+\_\+\+THREAD\+\_\+\+NAME}
, \newline
\textbf{ SCHED\+\_\+\+VTY\+\_\+\+THREAD\+\_\+\+UNKNOWN}
 \}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static int \textbf{ get\+\_\+num\+\_\+cpus} (void)
\item 
static int \textbf{ parse\+\_\+cpu\+\_\+hex\+\_\+mask} (const char $\ast$str, cpu\+\_\+set\+\_\+t $\ast$cpuset, size\+\_\+t cpuset\+\_\+size)
\item 
static int \textbf{ generate\+\_\+cpu\+\_\+hex\+\_\+mask} (char $\ast$str, size\+\_\+t str\+\_\+buf\+\_\+size, cpu\+\_\+set\+\_\+t $\ast$cpuset, size\+\_\+t cpuset\+\_\+size)
\item 
static bool \textbf{ proc\+\_\+tid\+\_\+exists} (pid\+\_\+t tid)
\item 
static bool \textbf{ proc\+\_\+name\+\_\+exists} (const char $\ast$\textbf{ name}, pid\+\_\+t $\ast$res\+\_\+pid)
\item 
static enum \textbf{ sched\+\_\+vty\+\_\+thread\+\_\+id} \textbf{ procname2pid} (pid\+\_\+t $\ast$res\+\_\+pid, const char $\ast$str, bool applynow)
\item 
static int \textbf{ my\+\_\+sched\+\_\+setaffinity} (enum \textbf{ sched\+\_\+vty\+\_\+thread\+\_\+id} tid\+\_\+type, pid\+\_\+t \textbf{ pid}, cpu\+\_\+set\+\_\+t $\ast$cpuset, size\+\_\+t cpuset\+\_\+size)
\item 
\textbf{ DEFUN\+\_\+\+ATTR} (cfg\+\_\+sched\+\_\+cpu\+\_\+affinity, cfg\+\_\+sched\+\_\+cpu\+\_\+affinity\+\_\+cmd, \char`\"{}cpu-\/affinity (self$\vert$all$\vert$$<$0-\/4294967295$>$$\vert$THREADNAME) CPUHEXMASK [delay]\char`\"{}, \char`\"{}Set CPU affinity mask on a (group of) thread(s)\textbackslash{}\textbf{ n}\char`\"{} \char`\"{}Set CPU affinity mask on thread running the \textbf{ VTY\textbackslash{}n}\char`\"{} \char`\"{}Set CPU affinity mask on all process\textquotesingle{} \textbf{ threads\textbackslash{}n}\char`\"{} \char`\"{}Set CPU affinity mask on a thread with specified \textbf{ PID\textbackslash{}n}\char`\"{} \char`\"{}Set CPU affinity mask on a thread with specified thread \textbf{ name\textbackslash{}n}\char`\"{} \char`\"{}CPU affinity \textbf{ mask\textbackslash{}n}\char`\"{} \char`\"{}If set, delay applying the affinity mask now and let the app handle it at a later \textbf{ point\textbackslash{}n}\char`\"{}, CMD\+\_\+\+ATTR\+\_\+\+IMMEDIATE)
\item 
static int \textbf{ set\+\_\+sched\+\_\+rr} (unsigned int prio)
\item 
\textbf{ DEFUN\+\_\+\+ATTR} (cfg\+\_\+sched\+\_\+policy, cfg\+\_\+sched\+\_\+policy\+\_\+cmd, \char`\"{}policy rr $<$1-\/32$>$\char`\"{}, \char`\"{}Set the scheduling policy to use \textbf{ for} the \textbf{ process\textbackslash{}n}\char`\"{} \char`\"{}Use the SCHED\+\_\+\+RR real-\/\textbf{ time} scheduling \textbf{ algorithm\textbackslash{}n}\char`\"{} \char`\"{}Set the SCHED\+\_\+\+RR real-\/\textbf{ time} \textbf{ priority\textbackslash{}n}\char`\"{}, CMD\+\_\+\+ATTR\+\_\+\+IMMEDIATE)
\item 
\textbf{ DEFUN} (cfg\+\_\+sched, cfg\+\_\+sched\+\_\+cmd, \char`\"{}cpu-\/sched\char`\"{}, \char`\"{}Configure CPU Scheduler related settings\char`\"{})
\item 
\textbf{ DEFUN} (show\+\_\+sched\+\_\+threads, show\+\_\+sched\+\_\+threads\+\_\+cmd, \char`\"{}show cpu-\/sched threads\char`\"{}, SHOW\+\_\+\+STR \char`\"{}Show Sched section \textbf{ information\textbackslash{}n}\char`\"{} \char`\"{}Show information about running threads)\textbackslash{}\textbf{ n}\char`\"{})
\item 
static int \textbf{ config\+\_\+write\+\_\+sched} (struct \textbf{ vty} $\ast$\textbf{ vty})
\item 
int \textbf{ osmo\+\_\+cpu\+\_\+sched\+\_\+vty\+\_\+init} (void $\ast$tall\+\_\+ctx)
\begin{DoxyCompactList}\small\item\em Initialize sched VTY nodes. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+cpu\+\_\+sched\+\_\+vty\+\_\+apply\+\_\+localthread} (void)
\begin{DoxyCompactList}\small\item\em Apply cpu-\/affinity on calling thread based on VTY configuration. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
static struct \textbf{ sched\+\_\+vty\+\_\+opts} $\ast$ \textbf{ sched\+\_\+vty\+\_\+opts}
\item 
static struct \textbf{ cmd\+\_\+node} \textbf{ sched\+\_\+node}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Implementation to CPU / Threading / Scheduler properties from VTY configuration. 



\doxysubsection{Macro Definition Documentation}
\mbox{\label{cpu__sched__vty_8c_a369266c24eacffb87046522897a570d5}} 
\index{cpu\_sched\_vty.c@{cpu\_sched\_vty.c}!\_GNU\_SOURCE@{\_GNU\_SOURCE}}
\index{\_GNU\_SOURCE@{\_GNU\_SOURCE}!cpu\_sched\_vty.c@{cpu\_sched\_vty.c}}
\doxysubsubsection{\_GNU\_SOURCE}
{\footnotesize\ttfamily \#define \+\_\+\+GNU\+\_\+\+SOURCE}

