canorbal / 2_year_MIPT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MIPT programming, 2 курс

Программы, написанные на 2 курсе МФТИ (ГУ) в рамках курса информатики.


  • безопасное копирование файлов

    user@ubuntu:~$ gcc cp.c -o cp.out
    user@ubuntu:~$ cat example.txt
    Hello, world!
    user@ubuntu:~$ ./cp.out example.txt example_1.txt
    user@ubuntu:~$ cat example_1.txt
    Hello, world!
    user@ubuntu:~$
    
  • запуск процессов в соответствии с расписанием

    формат записи расписания:
    
    time_0 process_0 args
    time_1 process_1 args
    time_2 process_2 args
    ...
    time_n process_n argc
    
    
    user@ubuntu:~$ gcc executor.c -o executor.out
    user@ubuntu:~$ cat example.txt
    10 sleep 5
    6 echo Hello world
    2 ls -all
    1 sleep 10
    user@ubuntu:~$ ./executor.out example.txt
    total 96
    drwxr-xr-x   9 Roman  staff    306 Aug 11 13:15 .
    drwxr-xr-x@ 18 Roman  staff    612 May 17 14:24 ..
    -rw-r--r--@  1 Roman  staff   6148 Nov 12  2016 .DS_Store
    -rwxr-xr-x@  1 Roman  staff     51 Aug 11 13:15 example.txt
    -rw-r--r--@  1 Roman  staff   7867 Feb 20 21:41 executor.c
    -rwxr-xr-x   1 Roman  staff  13840 Aug 11 13:15 executor.o
    -rwxr-xr-x@  1 Roman  staff    785 Jan 12  2017 fork.c
    -rwxr-xr-x   1 Roman  staff    697 Feb 14 16:46 process.c
    -rw-r--r--   1 Roman  staff     51 Aug 11 13:15 tmp_sorted_programs.txt
    Hello world
    process echo ended with code 0
    process ls ended with code 0
    process sleep ended with code 0
    process sleep ended with code 0
    user@ubuntu:~$
    
  • shell

Реализация shell с пайплайнами и подсчетом количества байт на выходе

    user@ubuntu:~$ gcc shell.c -o shell.out
    user@ubuntu:~$ ./shell.out
    ***********SHELL*************
    **write down shell commands**

    ls
    age_profile_train.csv
    pipe.c
    shell.c
    shell.o
    readed 45 bytes
    ***********SHELL*************
    **write down shell commands**

    head shell.c
    #include <errno.h>
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/wait.h>
    #include <fcntl.h>
    #include <unistd.h>

    #define MAX_STRING_SIZE 256
    #define MAX_PROG_NAME_SIZE 16
    readed 198 bytes
    ***********SHELL*************
    **write down shell commands**

    who | wc -l
          3
    readed 9 bytes
    ***********SHELL*************
    **write down shell commands**

Занимает гораздо больше времени, чем cp

    user@ubuntu:~$ gcc signalcp.c -o signalcp.out
    user@ubuntu:~$ cat example.txt
    Hello, world!
    user@ubuntu:~$ ./signalcp.out example.txt example_1.txt
    user@ubuntu:~$ cat example_1.txt
    Hello, world!
    user@ubuntu:~$

About


Languages

Language:C++ 51.3%Language:C 48.7%