Conversation
Adding readme without git clone
…gle-mode file closing
Codecov Report
@@ Coverage Diff @@
## main #2 +/- ##
=======================================
Coverage ? 82.41%
=======================================
Files ? 7
Lines ? 887
Branches ? 0
=======================================
Hits ? 731
Misses ? 156
Partials ? 0 Continue to review full report at Codecov.
|
multi-thread/program-MT.c
Outdated
| int main(int argc, const char** argv) { | ||
| if (argc < 3) { | ||
| printf("Please pass a source path and a word to search\n"); | ||
| return -1; |
There was a problem hiding this comment.
main не должен возвращать отрицательный код
multi-thread/program-MT.c
Outdated
|
|
||
| //clock_t start = clock(); | ||
| string_size_pair* res = (string_size_pair *)word_search_mt(argv[2], file_list, files_amount, num_tr); | ||
| //clock_t end = clock(); |
There was a problem hiding this comment.
Мертвого кода в гитхабе быть не должно
| // return 0; | ||
| } | ||
|
|
||
| void clear_file_list(char*** file_list, size_t files_amount) { |
multi-thread/word_finder_MT.c
Outdated
| // чтобы не писать еще одну сортировку | ||
| sorted_by_size = create_word_search_result(file_list, files_amount); | ||
| if (!sorted_by_size) | ||
| goto free_file_sizes; |
There was a problem hiding this comment.
Убирай, без вариантов
| } | ||
| if (word_search(pattern, res, files_amount)) { | ||
| printf("Error | word_search failed in [%zu] thread \n", tr_no); | ||
| pthread_exit((void *) (2)); |
IlyaSaneev
left a comment
There was a problem hiding this comment.
Добавить результаты работы алгоритмов в ридми
Нет использования динамической библиотеки
Нет приемов по эффективной работе с кеш-памятью.
| // create_word_search_result_mt separates the file list for threads so each has | ||
| // approximately equal bytes in total and initializes complicated structure string_sizex2 array with | ||
| // amount of files in a thread's file list and initializes a 'res' field to save a searching statistics | ||
| string_sizex2* create_word_search_result_mt(size_t num_tr, char** file_list, size_t files_amount) { |
There was a problem hiding this comment.
Функцию нужно декомпозировать на несколько функций.
multi-thread/word_finder_MT.c
Outdated
| void* thread_searcher(void* args) { | ||
| if (!args) | ||
| pthread_exit((void*)(-1)); | ||
| const char* pattern = ((thread_searcher_data*)args)->pattern; |
There was a problem hiding this comment.
thread_searcher_data* searcher_data = (thread_searcher_data*)args;
и далее searcher_data->
| if (exit_status == -1 && join_status == 0) | ||
| join_status = -1; // fatal | ||
| if (exit_status == 2 && join_status == 0) | ||
| join_status = 2; // NULL pattern or word_search_result addr | non fatal | impossible to get here |
There was a problem hiding this comment.
А может ли быть такое что iый поток был fatal, а i + 1 уже не fatal? В этом случае join_status с -1 будет перезатерт на -2
| pthread_exit((void*)15); | ||
| } | ||
|
|
||
| string_size_pair* word_search_mt(const char* pattern, char** file_list, size_t files_amount, size_t num_tr) { |
There was a problem hiding this comment.
Аналогично функцию декомпозировать
| return (char*)content; | ||
| } | ||
|
|
||
| size_t check_str (const char* str, const char* pattern) { |
There was a problem hiding this comment.
Нужно много тестов на этот метод.
|
Исправил все замечания. Возможно, разбивка функции, создающей структуру, была ошибкой. Хоть она и занимала 90 строк, а не 60, как теперь, читать ее было легче. |
тесты пока не готовы, смейк для либ тоже