This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
cmc/3sem/seminars/l9/03.c
T
2025-04-13 21:48:15 +03:00

38 lines
775 B
C
Executable File

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <wait.h>
#include <errno.h>
// инвертированная сегментная таблица сегментов
// 32-х разрядная система
typedef struct
{
pid_t pid;
unsigned int VirtNum;
} page_record;
unsigned int
f(page_record *pagetable, unsigned int VAdr, int size_segtable)
{
pid_t pid = getpid();
unsigned int pagenum = VAdr >> (12); // 12 - размер страницы
for (int i = 0; i < size_segtable; i++) {
if (pagetable[i].VirtNum == pagenum && pagetable[i].pid == pid) {
return i << (32 - 12) + (VAdr << 20 >> 20);
}
}
return -1;
}
int
main(int argc, char *argv[])
{
return 0;
}