Skip to content

Commit

Permalink
Merge branch 'main' into feature/CFG-6-cpu_config
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Nicolás Savinelli authored Apr 15, 2022
2 parents 1d5ddbe + 2b5b367 commit 00222d1
Show file tree
Hide file tree
Showing 14 changed files with 865 additions and 64 deletions.
194 changes: 135 additions & 59 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,141 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Lib-Test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/shared/lib_test.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "cpu",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/cpu.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
"name": "Lib-Test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/shared/lib_test.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "cpu-Test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/cpu_test.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
"name": "Memory",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/memory.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "cpu",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/cpu.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "Console",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/console.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "cpu-Test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/cpu_test.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "Memory_test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/memory_test.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
"name": "Console-test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/console_test.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
]
]
}
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,21 @@ CPU_DIR=cpu
# ! Allways add your listed above directories here
# ? eg. DIRS =$(SERVER_DIR) $(CLIENT_DIR) $(MEMORY_DIR)
# TODO: Add the listed directories
DIRS = $(KERNEL_DIR) $(CPU_DIR)

DIRS = $(KERNEL_DIR) $(CPU_DIR) $(MEMORY_DIR) $(CONSOLE_DIR)

# * DO NOT FORGET TO ADD YOUR RULES IN ALL --------------------------------------------------------------------------------------------

# All rules
# ! Allways add your rule for modules in here
# ? eg. all: server client memory filesystem etc
# TODO: add your rules
all: lib kernel cpu
all: lib kernel cpu memory console

# This targets are not files
# ! Allways add your rules for modules in here too
# ? eg. .PHONY: server client memory filesystem etc [...] clean install test
# TODO: add your rules here
.PHONY: kernel clean install test lib cpu

.PHONY: kernel clean install test lib memory console cpu

# ! AVOID MODIFYING THIS SECTION ------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -111,5 +109,12 @@ lib:
# ? cd $(MEMORY_DIR) && $(MAKE_COMPILE)
kernel:
cd $(KERNEL_DIR) && $(MAKE_COMPILE)

cpu:
cd $(CPU_DIR) && $(MAKE_COMPILE)

memory:
cd $(MEMORY_DIR) && $(MAKE_COMPILE)

console:
cd $(CONSOLE_DIR) && $(MAKE_COMPILE)
2 changes: 2 additions & 0 deletions config/console.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
IP_KERNEL=127.0.0.1
PUERTO_KERNEL=8000
11 changes: 11 additions & 0 deletions config/memory.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PUERTO_ESCUCHA=8002
TAM_MEMORIA=4096
TAM_PAGINA=64
PAGINAS_POR_TABLA=4
RETARDO_MEMORIA=1000
ALGORITMO_REEMPLAZO=CLOCK-M
MARCOS_POR_PROCESO=4
RETARDO_SWAP=2000
PATH_SWAP=/home/utnso/swap

# TO DO: Define path swap
109 changes: 109 additions & 0 deletions console/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# C Makefile using gcc, gdb and valgrind.
# Modified version of Makefile using g++ & gdb by Roberto Nicolas Savinelli <rsavinelli@est.frba.utn.edu.ar>
# Tomas Agustin Sanchez <tosanchez@est.frba.utn.edu.ar>

# ? Most defined will not required further modifycation -----------------------------------------------------------------------------------

# C Compiler
CC = gcc
# Compiler Flags
CFLAGS = -Wall -Wextra -g3
# Test Compiler flags
TCFLAGS = -Wall -Wextra -Wshadow -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-variable -Wno-pragmas -O3 -g3
# Used libraries
# * Add libraries when needed
LIBS = -lreadline -lcommons -pthread
#Log Folder
LOG_FOLDER=../log
# Build Folder
BUILD_FOLDER=../build
# Include directory
INCLUDE_DIRECTORY=./include/ ../lib/inc/
# Source directory
SOURCE_DIRECTORY=./src
# Test Directory
TEST_DIRECTORY=./test
# The main file path
MAIN_FILE= ./src/main.c
# The shared library source directory
LIB_DIRECTORY= ../lib/src
# Inlcude folder
# ? Loops [includeDirectory].forEach(includeDirectory => concat("-I ", "includeDirectory"))
INCLUDES = $(foreach dir, $(shell find $(INCLUDE_DIRECTORY) -type d -print), $(addprefix -I , $(dir)))
# The shared library source files
LIB_SOURCES = ../shared/*.o
# Source files
# ? Obtains all source files except MAIN
SOURCES = $(filter-out $(MAIN_FILE), $(shell find $(SOURCE_DIRECTORY) -name '*.c')) $(LIB_SOURCES)
# Test cases files
# ? Obtains all test source files
TESTS = $(shell find $(TEST_DIRECTORY) -name '*.c')
# Module name
# ! auto-generated module name (name of directory)
# ? eg. /user/home/dev/so-starter/memory will be memory
MODULE_NAME = $(notdir $(shell pwd))
# Output file name
OUTPUT = $(BUILD_FOLDER)/$(MODULE_NAME).out
# Test Output file
TEST_OUTPUT = $(BUILD_FOLDER)/$(MODULE_NAME)_test.out
# Leaks log file
LEAKS = $(LOG_FOLDER)/$(MODULE_NAME)_leaks.log
# Thread chek log file
HELGRIND = $(LOG_FOLDER)/$(MODULE_NAME)_threads.log


all : compile run

.PHONY: all

# ! Avoid modifying this section - (Unless you know what you are doing) --------------------------------------------------------------

# Compilation rule
# ? Generates .out executable
compile:
@mkdir -p $(BUILD_FOLDER)
@mkdir -p $(LOG_FOLDER)
@echo Building module: [$(MODULE_NAME)]...
$(CC) $(CFLAGS) $(MAIN_FILE) $(SOURCES) $(INCLUDES) $(LIBS) -o $(OUTPUT)
@echo Build completed.

# Compiles & Runs executable
# Test compilation
# ? Generates *_test.out executable
run: compile
./$(OUTPUT)

# Test compilation
# ? Generates *_test.out executable
test-build:
@mkdir -p $(BUILD_FOLDER)
@echo Preparing tests...
$(CC) $(TCFLAGS) $(TESTS) $(SOURCES) $(INCLUDES) $(LIBS) -o $(TEST_OUTPUT)
@echo Test builds!

# Runs tests cases
test: test-build
@echo Running test cases...
./$(TEST_OUTPUT)
@echo Tests completed.

# ! Uses Valgrind MemCheck tool
leaks: compile
@mkdir -p log
valgrind --leak-check=yes --log-file="$(LEAKS)" --track-origins=yes ./$(OUTPUT)

# ! Uses Valgrind Helgrind tool
threads: compile
@mkdir -p log
valgrind --tool=helgrind --log-file="$(HELGRIND)" ./$(OUTPUT)

# Removes Output files
clean:
$(RM) ./$(OUTPUT)
$(RM) ./$(TEST_OUTPUT)

# Removes log files
cleanLogs:
$(RM) -r $(LOG_FOLDER) || true

remove: clean cleanLogs
Loading

0 comments on commit 00222d1

Please sign in to comment.