-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move set_affinity(), print_time(), and dbg() to utils.c Add version.h Bump priority to both threads Make the data gathering thread use CPU 1 Make the udp thread use CPU 0
- Loading branch information
Showing
9 changed files
with
85 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#define _GNU_SOURCE | ||
|
||
#include <stdio.h> // perror, snprintf, fopen, FILE, fgets, fwrite, fclose | ||
#include <time.h> // time_t, time(), ctime, gmtime, struct tm | ||
#include <string.h> // strlen | ||
#include <pthread.h> // pthread_create, pthread_setaffinity_np, CPU_ZERO, CPU_SET | ||
|
||
#include "sysmond.h" | ||
#include "utils.h" | ||
|
||
// Globals | ||
char* time_string; | ||
|
||
// Start functions | ||
|
||
// Populate time_string with formatted time without newline | ||
void print_time() | ||
{ | ||
const time_t now = time( NULL ); | ||
time_string = ctime( &now ); | ||
time_string[ 24 ] = 0; // Remove newline | ||
} | ||
|
||
// Write txt to debug file | ||
void dbg( char* txt ) | ||
{ | ||
FILE* file; | ||
|
||
file = fopen( sysmond_args.dbgFile, "a" ); | ||
if ( file != NULL ) | ||
{ | ||
print_time(); | ||
strcat( time_string, " " ); | ||
fwrite( time_string, | ||
strlen( time_string ), | ||
1, | ||
file ); | ||
|
||
fwrite( txt, | ||
strlen( txt ), | ||
1, | ||
file ); | ||
|
||
fclose( file ); | ||
} | ||
} | ||
|
||
// Attach a process/threaad to a specific CPU | ||
void set_affinity( int cpu ) | ||
{ | ||
cpu_set_t mask; | ||
|
||
CPU_ZERO( &mask ); | ||
CPU_SET( cpu, &mask ); | ||
pthread_setaffinity_np( pthread_self(), sizeof(mask), &mask ); | ||
// Ignore result | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
void set_affinity( int ); | ||
void print_time ( void ); | ||
void dbg ( char* ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#define VERSION "3.0.0" | ||
|