y_socket: transfert kill to extern, y_nnn: debug leak mem
This commit is contained in:
@@ -389,7 +389,7 @@ char *fileNameDateScore(char * pre, char* post,size_t score){
|
||||
|
||||
const char* target_symlink = ".ff_target_.symlink";
|
||||
const char* main_symlink = ".ff_main_.symlink";
|
||||
|
||||
const char* dest_folder=".ff_learnDir";
|
||||
|
||||
void* learn_to_drive(void * lrnarg){
|
||||
struct RL_agent *rlAgent = (struct RL_agent *)lrnarg;
|
||||
@@ -402,7 +402,16 @@ void* learn_to_drive(void * lrnarg){
|
||||
//struct print_params * pprint = rlAgent->pprint;
|
||||
char msg[100];
|
||||
|
||||
////pthread_t threadPrint;
|
||||
if(mkdir(dest_folder, 0700)==-1){
|
||||
if(errno != EEXIST){
|
||||
perror(" create folder dst\n");
|
||||
}
|
||||
}
|
||||
else{
|
||||
printf("debug: %s successfully created\n",dest_folder);
|
||||
}
|
||||
|
||||
////pthread_t threadPrint;
|
||||
////pthread_create(&threadPrint, NULL, runPrint, (void*)rlAgent);
|
||||
|
||||
// while(true){
|
||||
@@ -429,7 +438,7 @@ void* learn_to_drive(void * lrnarg){
|
||||
if(car_status->cumulative_reward > qlStatus->progress_best_cumul->end_list->value){
|
||||
|
||||
push_back_list_TYPE_L_INT(qlStatus->progress_best_cumul, car_status->cumulative_reward);
|
||||
char *file = fileNameDateScore(".ff_main_",".txt",car_status->cumulative_reward);
|
||||
char *file = fileNameDateScore(".ff_learnDir/.ff_main_",".txt",car_status->cumulative_reward);
|
||||
EXPORT_TO_FILE_TENSOR_ATTRIBUTE_IN_NNEURONS(TYPE_FLOAT, rlAgent->networks->main_net ,weight_in, file);
|
||||
unlink(main_symlink);
|
||||
if(symlink(file, main_symlink)==-1){
|
||||
@@ -438,7 +447,7 @@ void* learn_to_drive(void * lrnarg){
|
||||
}
|
||||
else write(1,":",1);
|
||||
free(file);
|
||||
file = fileNameDateScore(".ff_target_",".txt",car_status->cumulative_reward);
|
||||
file = fileNameDateScore(".ff_learnDir/.ff_target_",".txt",car_status->cumulative_reward);
|
||||
EXPORT_TO_FILE_TENSOR_ATTRIBUTE_IN_NNEURONS(TYPE_FLOAT, rlAgent->networks->target_net ,weight_in, file);
|
||||
unlink(target_symlink);
|
||||
if(symlink(file, target_symlink)==-1){
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
#include <unistd.h>
|
||||
#define Sleep(x) usleep((x)*1000)
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "neuron_t/neuron_t.h"
|
||||
#include "neuron_t/nneuron_t_file.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
|
||||
@@ -35,22 +35,38 @@ void y_nnn_manager_handle_input(char * buf, int len_buf, void *arg){
|
||||
launch_sleep_wait_bash(bash_arg);
|
||||
}else if(strncmp(buf,"killbash",8)==0){
|
||||
kill_all_bash(bash_arg);
|
||||
}else if(strncmp(buf,"stoplearn",9)==0){
|
||||
}else if((strncmp(buf,"kill",4)==0) || (strncmp(buf,"stoplearn",9)==0)){
|
||||
kill_all_bash(bash_arg);
|
||||
pthread_mutex_lock(rlAgent->status->mut_ending);
|
||||
rlAgent->status->ending=1;
|
||||
pthread_mutex_unlock(rlAgent->status->mut_ending);
|
||||
|
||||
kill_all_bash(bash_arg);
|
||||
}else if(strncmp(buf,"startprintnewbash",17)==0){
|
||||
}else if(strncmp(buf,"stopprint",9)==0){
|
||||
pthread_mutex_lock(bash_arg->mut_bash_var);
|
||||
bash_arg->go_on=0;
|
||||
pthread_mutex_unlock(bash_arg->mut_bash_var);
|
||||
if(bash_arg->thread_run_newbash)
|
||||
pthread_join(*(bash_arg->thread_run_newbash),NULL);
|
||||
if(bash_arg->thread_run_waitbash)
|
||||
pthread_join(*(bash_arg->thread_run_waitbash),NULL);
|
||||
|
||||
|
||||
}else if(strncmp(buf,"goonprint",9)==0){
|
||||
pthread_mutex_lock(bash_arg->mut_bash_var);
|
||||
bash_arg->go_on=1;
|
||||
pthread_mutex_unlock(bash_arg->mut_bash_var);
|
||||
}else if(strncmp(buf,"startprintnewbash",17)==0){
|
||||
run_newbash(bash_arg);
|
||||
bash_arg->thread_run_newbash=malloc(sizeof(pthread_t));
|
||||
if(bash_arg->thread_run_newbash==NULL)
|
||||
bash_arg->thread_run_newbash=malloc(sizeof(pthread_t));
|
||||
pthread_create(bash_arg->thread_run_newbash, NULL, runBashPrint, arg);
|
||||
//pthread_t thread_run;
|
||||
//pthread_create(&thread_run, NULL, runBashPrint, arg);
|
||||
//Sleep(2);
|
||||
|
||||
}else if(strncmp(buf,"startprintwaitbash",18)==0){
|
||||
bash_arg->thread_run_waitbash=malloc(sizeof(pthread_t));
|
||||
if(bash_arg->thread_run_waitbash==NULL)
|
||||
bash_arg->thread_run_waitbash=malloc(sizeof(pthread_t));
|
||||
pthread_create(bash_arg->thread_run_waitbash, NULL, run_sleep_wait_bash_and_print, arg);
|
||||
//pthread_t thread_run;
|
||||
//pthread_create(&thread_run, NULL, run_sleep_wait_bash_and_print, arg);
|
||||
@@ -103,7 +119,7 @@ void* runBashPrint(void *arg){
|
||||
wait_valid_pid_bash(bash_arg);
|
||||
|
||||
printf("debug: start runBashPrint in episode: %ld\n",qlStatus->index_episode);
|
||||
while((new_bash_exist(bash_arg)) && check_go_on_print_params(pprint) && !is_ending(qlStatus)){
|
||||
while( check_go_on_bash(bash_arg) && (new_bash_exist(bash_arg)) && check_go_on_print_params(pprint) && !is_ending(qlStatus)){
|
||||
if(/*(qlStatus->nb_episodes %125 == 0) &&*/ pprint->printed){
|
||||
//pthread_mutex_lock(&(pprint->mut_printed));
|
||||
pthread_mutex_lock(&(car->mut_coord));
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
GEN_LIST_ALL(pid_t)
|
||||
|
||||
|
||||
/* return max pidof target, and if m_pid_t is not NULL, put into it all pids */
|
||||
/* return last modified pidof target, and if m_pid_t is not NULL, put into it all pids */
|
||||
pid_t pidof(char *target, struct main_list_pid_t *m_pid_t){
|
||||
pid_t maxpid=0;
|
||||
pid_t lastModifiedPid=0;
|
||||
ssize_t refModified=0;
|
||||
struct dirent *entry;
|
||||
DIR *proc = opendir("/proc"); /* */
|
||||
|
||||
@@ -41,7 +42,13 @@ pid_t pidof(char *target, struct main_list_pid_t *m_pid_t){
|
||||
name[status-1]=0;
|
||||
if(strcmp(name,target)==0){
|
||||
pid_t valpid=(pid_t)atol(entry->d_name);
|
||||
if(maxpid<valpid) maxpid=valpid;
|
||||
struct stat attr;
|
||||
stat(path, &attr);
|
||||
ssize_t modifPathDate = attr.st_mtime;
|
||||
if(refModified<modifPathDate) {
|
||||
lastModifiedPid=valpid;
|
||||
refModified=modifPathDate;
|
||||
}
|
||||
if(m_pid_t){
|
||||
push_back_list_pid_t(m_pid_t,valpid);
|
||||
}
|
||||
@@ -51,7 +58,7 @@ pid_t pidof(char *target, struct main_list_pid_t *m_pid_t){
|
||||
}
|
||||
closedir(proc);
|
||||
|
||||
return maxpid;
|
||||
return lastModifiedPid;
|
||||
}
|
||||
/* to write in an open bash terminal */
|
||||
int sprintbashpid(pid_t pid, char *content, size_t size_content){
|
||||
|
||||
@@ -347,8 +347,8 @@ EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->main_net, weigh
|
||||
EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->target_net, weight_in, ".ff_target_20240717_01h42m16s_5300.txt");
|
||||
*/
|
||||
|
||||
//EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->main_net, weight_in, ".ff_main_20240717_09h11m09s_1700.txt");
|
||||
//EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->target_net, weight_in, ".ff_target_20240717_09h11m09s_1700.txt");
|
||||
EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->main_net, weight_in, ".ff_main_.symlink");
|
||||
EXTRACT_FILE_TO_TENSOR_ATTRIBUTE_NNEURONS(TYPE_FLOAT, nnetworks->target_net, weight_in, ".ff_target_.symlink");
|
||||
|
||||
struct status_qlearning *qlstatus = create_status_qlearning ();
|
||||
struct delay_params *dly = create_delay_params (
|
||||
|
||||
@@ -347,6 +347,10 @@ void* y_socket_handler_(void *arg){
|
||||
}
|
||||
else if(len_buf >7 && strncmp(buf, "update", 6)==0){
|
||||
if(strncmp(buf+7,"kill",4)==0){
|
||||
|
||||
if(sock->var->extern_socket_handler){
|
||||
sock->var->extern_socket_handler("kill",4,sock->var->extern_arg);
|
||||
}
|
||||
pthread_mutex_lock(sock->mut_go_on);
|
||||
sock->go_on = 0;
|
||||
pthread_mutex_unlock(sock->mut_go_on);
|
||||
@@ -610,6 +614,9 @@ if(buf_len>6){
|
||||
}else if(buf_len && strncmp(buf, "help", 4)==0){
|
||||
usage_cmdl();
|
||||
}else if(buf_len && strncmp(buf, "kill", 4)==0){
|
||||
if(var->extern_socket_handler){
|
||||
var->extern_socket_handler(buf,buf_len,var->extern_arg);
|
||||
}
|
||||
pthread_mutex_lock(argSock->mut_go_on);
|
||||
argSock->go_on = 0;
|
||||
pthread_mutex_unlock(argSock->mut_go_on);
|
||||
|
||||
Reference in New Issue
Block a user