1
0

OS lb-7 mark

This commit is contained in:
Sytnyk Yehor
2025-05-27 23:23:28 +03:00
parent a63c29ff99
commit 28ccfa72ac
6 changed files with 19 additions and 12 deletions

View File

@ -1,7 +1,7 @@
> [!NOTE]
> Викладач: Мельникова Р. В.
>
> Оцінка: in progress
> Оцінка: 92
> [!TIP]
> Виконано для Linux в команді.

View File

@ -123,7 +123,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "Error: please provide time in UNIX timestamp format.\n");
return 1;
}
time_t norm_time = mktime(&tm);
time_t mtime = mktime(&tm);
char *paths[] = {CWD, NULL};
FTS *fts = fts_open(paths, FTS_NOCHDIR, NULL);
@ -134,10 +134,11 @@ int main(int argc, char *argv[]) {
char *buf = (char *)malloc(1024 * sizeof(char));
for (FTSENT *ent = fts_read(fts); ent != NULL; ent = fts_read(fts)) {
FTSENT *ent;
while ((ent = fts_read(fts)) != NULL) {
switch (ent->fts_info) {
case FTS_F:
if (ent->fts_statp->st_mtime > norm_time) {
if (ent->fts_statp->st_mtime > mtime) {
printf(RED);
printf("--------------------------------\n");
@ -167,6 +168,12 @@ int main(int argc, char *argv[]) {
Encoding enc = get_encoding(buf, bytes_read);
printf("Lines length:");
if (enc != ENC_UTF8)
buf = to_utf8(buf, bytes_read, enc);
enc = ENC_UTF8;
size_t lines = 0;
size_t line_len = 0;
for (size_t i = (enc == 2 || enc == 1) ? 2 : 0; i < bytes_read; i++) {
@ -204,9 +211,6 @@ int main(int argc, char *argv[]) {
}
printf("\nTotal lines: %zu\n", lines);
if (enc != ENC_UTF8)
buf = to_utf8(buf, bytes_read, enc);
printf(NORMAL);
printf("%s\n", buf);

View File

@ -3,7 +3,7 @@
#include <stdlib.h>
#include <time.h>
#define MATRIX_SIZE 512
#define MATRIX_SIZE 12
typedef struct {
double **a;
@ -134,7 +134,7 @@ int main() {
double sequential_time = measure_time_seq(mul_seq, a, b, r_seq, MATRIX_SIZE);
printf("time: %f secinds\n", sequential_time);
int num_threads = 32;
int num_threads = 8;
printf("\nperforming parrallel multiplication (%d threads)...\n",
num_threads);
double parallel_time =

View File

@ -4,12 +4,15 @@
#define NUM_THREADS 10
volatile size_t count = 0;
void *thread_function(void *thread_id) {
long tid = (long)thread_id;
printf("Begin\t%ld\n", tid);
for (int i = 0; i < 100000; ++i)
;
printf("End\t%ld\n", tid);
count++;
pthread_exit(NULL);
}
@ -23,7 +26,7 @@ int main() {
void *status;
pthread_join(threads[0], &status);
printf("Main thread completed execution\n");
printf("Main thread completed execution\nCount: %zu\n", count);
return 0;
}