Exame de Época Recurso Nome: Número: Parte Teórica (45 minutos, sem consulta) 1. (5) Classifique cada uma das alíneas seguintes como Verdadeira ou Falsa. 1.1. Num sistema baseado no processador Intel Core i5 em modo protegido, a) o barramento externo de endereços tem 64 bits de largura. b) as Call Gates localizam-se na tabela de páginas. c) são utlizados dois TLB (Tanslation Lookaside Buffer) integrados. d) as páginas de memória podem são alinhadas em endereços múltiplos de 8KiBytes. e) existe um registo RAX com 64 bits. f) os registos selectores de segmentos têm 32 bits. g) pode ser utilizado um mecanismo de segmentação de memória a dois níveis. h) a dimensão de uma página de memória é definida na tabela de páginas. 1.2. a) O processador Intel Pentium possui uma unidade integrada para processamento de dados em vírgula flutuante. b) O processador Intel 386DX possui uma memória de cache integrada. c) O processador Intel Pentium III possui uma unidade computacional SSE. d) Um processador Intel Pentium 4 utiliza um Buffer de Reordenação. e) O processador Intel Pentium III utiliza dois TLBs distintos. f) Um BTB (Branch Target Buffer) só se justifica em arquitecturas com várias pipelines. g) Um TLB (Tanslation Lookaside Buffer) só se justifica em arquitecturas com paginação de memória. h) Cada núcleo (core) de um processador possui o seu próprio registo IP (Instruction Pointer). 1.3. a) Uma cache vítima utiliza-se normalmente em conjunto com uma cache de mapeamento direto. b) É possível utilizar políticas de leitura do tipo No-Read-Through com uma cache virtual. c) Uma cache pode utilizar blocos de dados mais largos do que o barramento de dados do processador. d) É possível utilizar políticas de escrita do tipo Write-Back com uma cache completamente associativa. e) A taxa global de falhas num nível de cache pode ser superior à taxa local de falhas no mesmo nível. f) Uma cache vítima pode ter uma arquitetura de mapeamento direto. g) Uma cache completamente associativa pode ser gerida por políticas de substituição do tipo LRU (Least Recently Used) h) Uma cache externa é sempre fisicamente etiquetada.
1.4. a) Utilizando o LVM (Logical Volume Manager), um sistema de ficheiros pode utilizar espaço de vários dispositivos de armazenamento. b) Cada partição tem uma tabela de partições. c) Um bootloader pode utilizar recursos do Kernel do sistema operativo. d) A localização de um bootloader é definida na tabela de partições. e) O Journaling permite juntar, no mesmo directório, conteúdos alojados em dispositivos distintos. f) Os sistemas de ficheiro do tipo EXT2 utilizam Journaling. g) É possível criar um sistema de ficheiros do tipo EXT3 num ficheiro. h) Um sistema de ficheiros do tipo UnionFS garante a recuperação da informação após uma de falha de energia. 1.5. a) A tarefa de configuração do kernel Linux é normalmente realizada antes da sua compilação. b) O buildroot é um módulo do kernel Linux. c) Uma aplicação pode utilizar funcionalidades disponibilizadas pelo kernel Linux. d) Os ficheiros de dispositivos (device files) residem normalmente no directório /proc/devices e) A lista de módulos carregados pode ser obtida com o comando lsmod f) Num sistema Linux, os módulos de kernel encontram-se normalmente localizados no directório /dev. g) Os ficheiros de dispositivos são criados durante a compilação do kernel. h) O comando modprobe pode ser utilizado para carregar módulos de sistema operativo. 2. (2) Alguns processadores utilizam um barramento externo de dados mais largo do que os registos internos de uso genérico. Comente esta afirmação, referindo exemplos de processadores que conhece. Justifique esta opção técnica e as consequências respectivas. 3. (1) As extensões SSE (Streaming SIMD Extensions) incluídas em alguns processadores Intel e AMD utilizam um conjunto de registos próprio. a) Quantos são estes registos? b) Qual a dimensão destes registos? c) Que tipos de dados podem ser tratados a partir destes registos? 4. (2) Um determinado fabricante pretende adicionar à sua linha de processadores uma memória cache de 1MiByte, organizada em blocos de 64 Bytes e com uma arquitetura associativa por conjuntos com 8 vias. Sabendo que os processadores em causa possuem barramentos de endereços de 36 bits, barramento de dados de 64 bits e que utilizam endereçamento ao Byte, indique qual deverá ser, para esta cache: a) O número de comparadores. b) O número de bits utilizados na indexação. c) A dimensão das etiquetas.
Parte Prática (50 minutos, com consulta; não é permitida a utilização de dispositivos eletrónicos com capacidades computacionais) 5. a) (1,5) Apresente a sequência de comandos necessários para proceder à copia do conteúdo do diretório build/bin (incluindo eventuais diretórios) para a raiz da 2ª partição do 3º dispositivo de armazenamento do sistema. Essa partição não se encontra montada. b) (1) Apresente os comandos necessários para criar um ficheiro, volume.img, de 4 MiB cujo conteúdo é um sistema de ficheiros do tipo ext4. c) (0,5) Numa máquina de desenvolvimento, foi executado o comando abaixo: [user@localhost]$ gcc -o appmgr main.o interface.o -lutils -static Após a execução do comando, encontram-se os seguintes ficheiros no diretório atual: makefile, appmgr, libutils.a, libutils.so, appmgr.h, interface.o, main.o, utils.o, interface.c, main.c e utils.c. Que ficheiros devem ser copiados para o sistema alvo de forma a obter uma aplicação funcional? 6. Considere um processador da família x86 a funcionar em modo real em que o estado de alguns dos registos é o apresentado na tabela seguinte: AX BX CX DX SI DI Listagem 1 0xFF00 0x300 0x4AA 0x4A0 0x5C0 0x7D0 BP SP CS DS SS ES 0x100 0x40A 0x100 0x609 0x4400 0x5000 mov [bx+0x10], ax mov si, #0x10 mov cx, [bx+si] mov bp, sp mov [bp+di+0x80], cx Listagem 2 entry start start: run_system isr_counter: iret a) i) (2,5) Determine os endereços físicos das posições de memória lidas ou escritas pela sequência de instruções da Listagem 1. ii) (0,5) Indique o valor contido no registo CX após a execução da sequência de instruções da Listagem 1. b) (1,5) Faça as alterações necessárias ao programa da Listagem 2 de modo que a rotina isr_counter seja a função de atendimento da interrupção 0x40. Assuma que o programa é carregado no endereço 0xF0000. 7. Considere o seguinte extrato do código fonte de um módulo de kernel Linux: struct file_operations fops = {.owner = THIS_MODULE,.open = mydriver_open,.read = mydriver_read,.write = mydriver_write,.close = mydriver_close, }; int init_module(void) { return register_chrdev("mgrdrv", 3000, &fops); } a) (1) Assumindo que o módulo de kernel já foi gerado e o seu nome é mgrdrv.ko, apresente a sequência de comandos necessária para carregar o módulo e criar um ficheiro de dispositivo para este módulo com nome /dev/mgrdrv. b) (0,75) Indique em que situação a a função init_module é normalmente executada. c) (0,75) Assumindo que os passos descritos na alínea a) são corretamente executados, descreva o efeito da execução do seguinte comando na shell: cat /dev/mgrdrv
Exam of Supplementary Epoc Name: Number: Theoretical Part (45 minutes, without consultation) 1. (5) Classify each of the following as True or False statements. 1.1. In an Intel Core i5 processor running in protected mode a) the width of the external address bus is 64 bits. b) Call Gates are stored in page table. c) two integrated TLB (Translation Lookaside Buffer) are used. d) memory pages can be aligned at addresses multiple of 8KiBytes. e) there is a register RAX with 64 bits. f) segment selector registers have 32 bits. g) memory segmentation process can be done in two levels. h) each memory page has its size defined in the page table 1.2. a) The Intel Pentium processor includes a floating point unit. b) The Intel Core 386DX processor includes an integrated cache memory. c) The Intel Pentium III processor includes a computational unit SSE. d) The Intel Pentium 4 uses a Reorder Buffer. e) The Intel Pentium III processor uses two distinct TLBs (Translation Lookaside Buffers). f) A BTB (Branch Target Buffer) is only required by architectures with several processing pipelines. g) A TLB (Translation Lookaside Buffer) is only required by architectures with memory paging. h) Each processor core includes its own IP (Instruction Pointer) register. 1.3. a) A victim cache is usually applied together with a direct mapped cache. b) It is possible to apply No-Read-Through policies with virtual caches. c) A cache memory can store data blocks wider than the processor data bus. d) It is possible to apply Write-Back policies with fully associative caches. e) The global miss rate at a given cache level can be higher than the local miss rate at the same level. f) A victim cache should be directly mapped. g) A fully associative cache can be managed by LRU (Least Recently Used) replacement policies. h) An external cache is always physically tagged.
1.4. a) When using LVM (Logical Volume Manager), a file system can use space from several storing devices. b) Each partition has its own partitions table. c) A bootloader can use resources implemented by the operating system kernel. d) The location of a bootloader is defined in the partitions table. e) Journaling allows joining, in the directory, contents stored in different devices. f) EXT2 file systems use Journaling. g) An EXT3 file system can be created in a file. h) A UnionFS allows restoring data after a power fail. 1.5. a) The Linux kernel configuration is usually performed before compiling it. b) The buildroot is a Linux kernel module. c) An application can use resources made available by the Linux kernel. d) Device files are usually stored in the /proc/devices directory. e) The list of the loaded modules can be obtained using the command lsmod f) In a Linux system, the kernel modules are usually stored in the /dev directory. g) Device files are special files that are created during the kernel compilation. h) The modprobe command can be used to load operating system modules. 2. (2) Some processors use an external data bus wider than the general propose internal registers. Comment this statement and refer some examples from known processors. Point out the main advantages and disadvantages related to this technical option. 3. (1) The SSE (Streaming SIMD Extensions) included in some Intel and AMD processors use a dedicated set of registers. a) How many registers are in this set? b) Which size are these registers? c) Which data types can be processed from these registers? 4. (2) A processor maker wants to add to its family of processors a new cache memory with 1MiByte, organized into data blocks of 64 Bytes and an 8-way set associative architecture. These processors have 36 bits address buses, 64 bits data bus and the memory is Byte addressable. For this cache, indicate a) The number of comparators. b) The number of bits used for indexing. c) The Tag size.
Practical Part (50 minutes, open book; computer, smartphone and any devices with computing capabilities are not allowed) 5. a) (1,5) Present the required sequence of commands to copy the contents of the directory build/bin (including any subdirectories) to the root directory of the 2nd partition of the 3rd storage device of the host machine. This partition is unmounted. b) (1) Present the required commands to create a 4 MiB file, volume.img, whose content is an empty ext4 file system. c) (0,5) The following command was executed in a development machine: [user@localhost]$ gcc -o appmgr main.o interface.o -lutils -static After the execution of the command, the following files are found in the working directory: makefile, appmgr, libutils.a, libutils.so, appmgr.h, interface.o, main.o, utils.o, interface.c, main.c and utils.c. Which files should be copied to the target machine in order to get a functional application? 6. Consider a microprocessor from the x86 family, working in real-mode. The state of the microprocessor registers is presented in the table below: AX BX CX DX SI DI Listing 1 0xFF00 0x300 0x4AA 0x4A0 0x5C0 0x7D0 BP SP CS DS SS ES 0x100 0x40A 0x100 0x609 0x4400 0x5000 mov [bx+0x10], ax mov si, #0x10 mov cx, [bx+si] mov bp, sp mov [bp+di+0x80], cx Listing 2 entry start start: run_system isr_counter: iret a) i) (2,5) Determine the physical address of each memory location addressed by the sequence of instructions in Listing 1. ii) (0,5) Determine the value stored on CX after the execution of the sequence of instructions in Listing 1. b) (1,5) Make the necessary changes to the program in Listing 2 such that isr_counter becomes the interrupt handling routine for interrupt 0x40. Assume the program is loaded at the physical address 0xF0000. 7. Consider the following extract from the source code of a Linux kernel module: struct file_operations fops = {.owner = THIS_MODULE,.open = mydriver_open,.read = mydriver_read,.write = mydriver_write,.close = mydriver_close, }; int init_module(void) { return register_chrdev("mgrdrv", 3000, &fops); } a) (1) Assuming the module was already built and was named mgrdrv.ko, present the required sequence of commands to load the module and to create a corresponding device file named /dev/mgrdrv. b) (0.75) In what situation is the init_module function usually executed? c) (0.75) Assuming the steps in question a) are correctly executed, describe the effect of the execution of the following command in the shell: cat /dev/mgrdrv