Skip to content

Instantly share code, notes, and snippets.

@asm95
asm95 / fit_algorithms.py
Last active July 11, 2019 19:53
Algoritmos de Alocação de Memória
# source: https://www.geeksforgeeks.org/program-best-fit-algorithm-memory-management/
def print_allocation(n, allocation, process_size):
print("Process No.\tProcess Size\tBlock no.")
for i in range(n):
print("%d\t\t%d\t\t" % (i+1, process_size[i]),
allocation[i] + 1 if allocation[i] != -1
else "Not Allocated", sep=''
)
def first_fit(block_size, process_size):
@asm95
asm95 / lexico.l
Created May 29, 2019 11:57
Analisador Semântico V1 (Tradutores 2019/1)
%{
# include "sintatico.tab.h"
# include <string.h>
%}
%%
([0-9]{1,})((\.)?[0-9]{1,})? {return NUM;}
("var") {return VAR;}
("leia") {return LEIA;}
("escreva") {return ESCREVA;}
("int"|"float") {yylval.id = (char *) strdup(yytext); return TIPO;}