> For the complete documentation index, see [llms.txt](https://hernandez-kevin.gitbook.io/pintos-vm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hernandez-kevin.gitbook.io/pintos-vm/virtual-memory/free-resources-part-2.md).

# Free Resources Part 2

Como pudiste observar, quedan muy pocas pruebas por pasar. Esas pruebas están relacionadas con esto último que es de liberar recursos.

Como última implementación de esta fase 3, debes de liberar los recursos utilizados por Mmap cuando un proceso está a punto de terminar.

Debes de recordar lo siguiente:

* Cerrando o removiendo un archivo no implica que todos los mapeos hechos de deben de unmapear. Esto solamente ocurre si se llama la función ***munmap()*** o el proceso termina su ejecución.
* Todos los mapeos son implícitamente unmapeados cuando un proceso termina su ejecución, sin importar el medio de cómo lo haga (ya sea un exit(), etc).

Con las premisas anteriores, podemos inferir que hay casos que un proceso mantiene todos sus mapeos incluso cuando está a punto de terminar su ejecución.\
Nosotros debemos de unmapear esos mapeos antes que dicho proceso termine su ejecución.

Un buen momento para hacer esta tarea es en ***process\_exit()***.

{% hint style="info" %}
Sí es importante el orden de cómo liberas los recursos. Es recomendable que liberes de primero todos los mapeos y de último liberes los recursos restantes.
{% endhint %}

## Make Grade

Ya con este último detalle, habrás terminado toda la fase 3.

¡Felicidades!

![](https://media.giphy.com/media/ui1hpJSyBDWlG/giphy.gif)

### Functionality

{% tabs %}
{% tab title="Stack Growth" %}

* [x] pt-grow-stack
* [x] pt-grow-stk-sc
* [x] pt-big-stk-obj
* [x] pt-grow-pusha
  {% endtab %}

{% tab title="Paging Behaviour" %}

* [x] page-linear
* [x] page-parallel
* [x] page-shuffle
* [x] page-merge-seq
* [x] page-merge-par
* [x] page-merge-mm
* [x] page-merge-stk
  {% endtab %}

{% tab title="Mmap System Call" %}

* [x] mmap-read
* [x] mmap-write
* [x] mmap-shuffle
* [x] mmap-twice
* [x] mmap-unmap
* [x] mmap-exit
* [x] mmap-clean
* [x] mmap-close
* [x] mmap-remove
  {% endtab %}
  {% endtabs %}

### Robustness

{% tabs %}
{% tab title="Page Table Support" %}

* [x] pt-bad-addr
* [x] pt-bad-read
* [x] pt-write-code
* [x] pt-write-code
* [x] pt-grow-bad
  {% endtab %}

{% tab title="Mmap System Call" %}

* [x] mmap-bad-fd
* [x] mmap-inherit
* [x] mmap-null
* [x] mmap-zero
* [x] mmap-misalign
* [x] mmap-over-code
* [x] mmap-over-data
* [x] mmap-over-stk
* [x] mmap-overlap
  {% endtab %}
  {% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hernandez-kevin.gitbook.io/pintos-vm/virtual-memory/free-resources-part-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
