2.10 Optimization management
β Optimize the computer
- File Management: FAT32
- RAM management: Segment, Paging
- Process management: FIFO, SJF
- IRQ/DRG: DMA, Polling, PIO
- ππ» All this make the computer overloaded
- ππ» We need to optimize the computer
β Priority of computer components
- CPU
- Main Memory RAM
- Secondary Memory (HDD, SSD)
- Peripherals
- ππ» We should optimize the computer components following this order
1οΈβ£ Lets help the CPU
π€ Problem that CPU suffers
- 1οΈβ£ speed problem, being slow β‘οΈ bottleneck problem
- 2οΈβ£ temperature problem π better refrigeration problem, better ventilation
π Solve the bottleneck problem
- Use CPU cache
CPU cacheis inside CPU- The
CPU cacheis divided into 4 potions
π‘ CPU cache is stable
- in general,
CPU cacheis not deleted CPU cacheis stable(not deleted after session finishes)- unless we manually clean them
4 types of CPU cache
- L1D: Level 1 Data cache
- For data that CPU uses very very often
- π
power of 2, as in computer everything is in binary, it is stored in cache for frequent access - π
1s and0s
- π
- βπ» one L1D per core
- it needs to be close to the CPU, as it is used very often to the nueman machine
π size: comparatively small, we just want them for super frequent things
- L1I: Level 1 Instructions cache
- for instructions that we use very very often
- π standard mathametical instructions, like
sum,minus,mul,div,move(move data to another space),sqrt(square root)
- π standard mathametical instructions, like
- βπ» one L1I per core
π size: comparatively small, we just want them for super frequent things
- L2: Level 2 Cache
- Both instructions and data mixed together that we use quite often
- π mathametical operations that are not so frequent:
log,cos function...
- π mathametical operations that are not so frequent:
- π size: bigger than level 1, need to save both instructions and data
- πΊοΈ location: located further away from the neuman machine, compared to level 1
βπ» one L1I per core
- shared L3: Level 3 Cache
- Both instructions and data we use sometimes
- π
loops, like for, while
- π
- π³ size: bigger, very big
- πΊοΈ location: far from neuman machine
- βπ» Shared level 3: Not one per core, shared among all the cores
- Level 3 cache uses front side bus
1
2
3
4
5
6
7
8
β If I have 8 cores, how many CPU caches do I have?
- L1D: 8
- L1I: 8
- L2: 8
- L3 : one shared L3 per core
ππ» in total 25 CPU cache memory
π‘ ISA
- Instructions Set Architecture
- set of instructions that the CPU needs to exectute
- the instructions that come by default when I buy my computer
- factory settings of my CPU
the instructions that the neuman machines do by default
CPU cachehelpsISA, as some ofISAinstructions are stored in theCPU cache
1
2
3
4
5
6
7
8
9
β If I reset my computer to factory settings, pure nueman machine, am I deleting the CPU cache memory?
ππ» yes, we are deleting
wβ hich element of the CPU cache helps the following?
- IPC to the kernel
- ISA
- IRQ
- DRQ
ππ» ISA
2οΈβ£ Lets help the RAM
π€ Problem that RAM suffers
- 1οΈβ£ problem of space: even smaller bc of
process table, pages table, vectors table, service routinesand above all, processes!
π Sharing
- there are some common portions that several proecesses share
- π
menu bar in word, excel, ppt are more or less the same - If some processes have some elements in common,
- then put the same elements just one time on the RAM
and share it among the processes
- ππ» the shared elements would be less secure
- as it can be accessed by several processes
- sharing can be deactivated
π Virtual Memory
βοΈ Some processes are ok to be slow and is not used so frequently
- can be slow
- is not used all the time
- we do not need the process to be there all the time in the RAM
βοΈ Page File and SWAP area
- we can leave the process in a specific part of the Harddisk(secondary memory)
- called in Page File
windows/mac/androidand SWAP area inlinux - ππ» in
page file/SWAP areawe store the pages of the process that - we donβt use very often
- and we do not need so fast
- like having an extra storage
- ππ» makes the RAM feel bigger than it seems
ππ» Feels like virtually, I have more RAM
- its called swap, bc when you need it,
- it seems the process is inside the RAM
But actually, the process is inside the hardddisk
- So in harddisk, it is generally for closed program
- but in SWAP part of harddisk, there are opened process
βοΈ Format for Page File and SWAP area
- This area is in the secondary memory
- β οΈ the format is different from starndard( NOT
FAT32,exFAT,NTFS,ext 2, 3, 4β) - the format of
Page FileandSWAP areais called swap - as
Page FileandSWAP areais for helping the RAM,swap formatis similar to the RAM
βοΈ Virtual Memory
- VIrtual Memory = my RAM β SWAP in Harddisk
VM π° MM β SWAP area(SM)
βοΈ Calculate the VM
- If RAM is small β¬οΈ SWAP must be big β¬οΈ
- If
RAM < 4GB, SWAP must be two times the RAMSWAP = RAM * 2 - If
RAM = 4GB, SWAP must be same as the RAMSWAP = RAM - If
RAM > 4GB, SWAP must be half of the RAMSWAP = RAM / 2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
β 3GB of RAM, my SWAP should be?
ππ» 6GB
β Then how much is my VM?
ππ» 9GB
------
β 4GB of RAM, my SWAP should be?
ππ» 4GB
β Then how much is my VM?
ππ» 8GB
------
β 16GB of RAM, my SWAP should be?
ππ» 8GB
β Then how much is my VM?
ππ» 24GB
β οΈ Error we can get if we do not follow the VM caculation rule
- If we follow these rules, we will never have a problem with the virtual memory
- However, if we do not follow these rules, we might get a problem
- cannot read instruction on
0x000000 if you see this error, you have a virtual memory problem
- this error occurs bc many OS take SWAP smaller than needed
- many OS prefer more pure HD than more SWAP
- π deactivate the automatic VM supply(administraciΓ³n automatica memoria virtual)
- π and supply VM manually
βοΈ Perfect limits for VM
SWAPshould always be between half and double the size of theRAMhalf of RAM< size of swap <double of RAM- if my RAM is big, if my SWAP small, SWAP is
half of RAMmy VM would beRAM + RAM/2 = 1.5RAM - if my RAM is small, if my SWAP big, SWAP is
twice the RAMmy VM would beRAM + RAM*2 = 3 RAM - Thus, the VM size should always be
RAM * 1.5< size of VM <RAM * 3- ππ» This size of VM would avoid the problem of VM
0xerror
1
2
3
4
β I have 8GB of RAM. Study the minimum and maximum limits of VM so I do not get the VM error.
ππ» 8 * 1.5 < VM size < 8 * 3
ππ» thus, 12GB < VM size < 24GB
ππ» as long as I guarantee that my computer makes VM from 12 to 24GB, I will never get the 0x error.
3οΈβ£ Lets help the HardDisk
π Harddisk Buffer
- buffer: temporal storage for making profit of a data transaction
π‘ proximity principle
- when you open a program, most probably you will need more than that
- ππ» open more, also the ones next to the pointed program
- π if you opened ejercicio 1, you will also open 2, 3,4β¦
- the extra can be stored in the
harddisk bufferto have it closer to you.
π Web cache, Broswer cache
- when we download elements from the web and we visit web pages
- most probably, we will use the element/web page later
- store the elements in the broswer cache
- web cache is a folder in the harddisk
- when we empty the cache, we are emptying the web cache
4οΈβ£ Lets help the
β
β
β
β
1οΈβ£
2οΈβ£
3οΈβ£
4οΈβ£
- 1οΈβ£
- 2οΈβ£
- 3οΈβ£
- 4οΈβ£ ππ» ππ»
1
2
3
4
5
6
7
8
9
10
11
βοΈβοΈβοΈ EXAM βοΈβοΈβοΈ
β
ππ»
------
β
ππ»
β
ππ»
β
ππ»





