Контрольная Работа: Операционные Системы
Формула оценки
Grade = 0.4 * Теория + 0.6 * Задача
Дедлайн
- Время начала: 13:30
- Время окончания: 15:00
Правила
Разрешается использовать консоль Linux и все утилиты, которые оттуда можно вызвать. Запрещается искать ответы в Интернете и использовать средства искусственного интеллекта. Политика по борьбе с плагиатом описана здесь.
Прокторинг
Запишите видео своего экрана + камера + звук при помощи OBS Studio,
загрузите его в облако и пришите ссылку через форму. Рекомендуемый формат видео .mkv (должно получиться относительно небольшим).
На видео должны быть обе части (теория и программа). Включите запись перед тем, как приступить к решению. Изображение с камеры поместить в верхний правый угол (размер ~1/8 экрана).
Видео: Ссылку на видео отправить в эту форму.
Форма для отправки видео останется открыта после окончания на случай, если загрузка займёт длительное время.
Форма
Форма для отправки ответов здесь.
Часть 1: Теория
Ответьте на вопросы по теории в форме для отправки ответов (см. выше).
Часть 2: Задача по программированию
Пришлите программу через форму для отправки ответов (см. выше).
Write a program in C that does the following:
- Calculates the value of the specified function
f(x)in the range fromargv[1]toargv[2]with stepargv[3]. - Writes pairs
x, f(x)into text fileoutput.csv(CSV format). - The function to be calculated has the following format:
f(x) = f0(f1(x), f2(x), f3(x), f4(x)), where:
xis the function argument;f0-f4are functions that are individual according to the variant.
Example of Function (you need your variant, see below)
Note: the ^ symbol means “power”.
f0(a, b, c, d) = (a - b + c - d) / 2
f1(x) = 2*x^3 - 4*x^2 + 3*x + 1
f2(x) = sin(5*x)*4 + 3
f3(x) = 1 / (1 + e^(-7*x))
f4(x) = 2^x + 5
Requirements and Grades
- 4 Points: make all calculations and write to file in a parent process; provide a Makefile to build the program;
- 5 Points: write to a file using output redirection (redirect the standard output to the file using dup2);
- 6 Points: make all calculations and write to the file in a child process (use fork);
- 8 Points: execute the f0 function for the entire value range in a child process and send the resulting values to the parent process using a pipe;
- 10 Points: execute f0 in the parent process and f1-f4 in separate child processes; return the calculated values of f1-f4 to f0 using a pipe (you will need 4 pipes).
Hints
- Function
f0have the following structure:double f0(double a, double b, double c, double d) { return <math expr>; } - Functions
f1-f4have the following structure:double f1(double x) { return <math expr>; } - Command-line arguments (strings) can be converted to
doubleusing the atof function. - Mathematical functions (such as
sin,cos,pow,expetc.) and constants (M_E) are in the math.h library. The program must be linked with the library: use the-lmGCC flag. - To write to a file, open the file and redirect the standard output
(
STDOUT_FILENO) to this file with the dup2 system call. When you do this, you will be able to useprintfto print to the file. If you do this in the parent process, redirection will work in both processes (parent and child). - Sending data from child to parent using a pipe: see example in the manual.
- Child:
f(x)is calculated for a range of values and results (xandf(x)) are written (write(pfd[1], &x, sizeof(x))) to the pipe; - Parent: results (
xandf(x)) are read (read(pfd[0], &x, sizeof(x))) from the pipe in a loop and printed.
- Child:
Варианты
Выберите свой номер варианта согласно своему номеру в списке группы.
Списки групп:
Варианты для групп: