SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
Gerenciamento de Mem´ria
                    o
Sonho dos usu´rios
                               a
Idealmente, a mem´ria deveria ser
                 o

 • r´pida,
    a
 • de custo baixo,
 • imensa e
 • n˜o vol´til.
    a     a
Realidade para os usu´rios
                                 a
                      Hierarquia de Mem´ria
                                       o

Typical access time                           Typical capacity


       1 nsec                 Registers         <1 KB
       2 nsec                  Cache             1 MB
      10 nsec               Main memory          64-512 MB
      10 msec               Magnetic disk        5-50 GB

     100 sec                Magnetic tape        20-100 GB
Hierarquia de Mem´ria
                          o
                   Registradores
• Internos ` CPU
           a
• Extremamente r´pidos
                a
• Otimiza¸oes de c´digo podem mover temporariamente
          c˜        o
  vari´veis para registradores.
      a
• Programas podem dar palpites sobre o que deve ficar
  armazenado nos registradores
  register int r;
Hierarquia de Mem´ria
                          o
                       Cache
• Internos ou muito pr´ximos ` CPU
                      o      a
• Divididos em linhas de cache
• Controlados por hardware
• Cache hit
• Cache miss
Hierarquia de Mem´ria
                          o
              Mem´ria Principal
                 o
• Random Access Memory (RAM)
• Compromisso entre pre¸o e desempenho
                       c
• Armazenamento vol´til
                   a
Hierarquia de Mem´ria
                        o
               Disco
                  Read/write head (1 per surface)
Surface 7

Surface 6
Surface 5

Surface 4
Surface 3
                          Direction of arm motion
Surface 2
Surface 1

Surface 0
Hierarquia de Mem´ria
                          o
                 Fitas magn´ticas
                           e
• Utilizadas para c´pias de seguran¸a (backups)
                   o               c
• Armazenamento de grandes quantidades de dados
• Acesso seq¨encial
            u
Hierarquia de Mem´ria
                          o
           Outros tipos de mem´ria
                              o
• ROM (Read Only Memory)
  – r´pida e barata
     a
  – bootstrap loader est´ gravado em ROM
                        a
• EEPROM (Electrically Erasable ROM)
  – podem ser apagadas (erros podem ser corrigidos)
• CMOS
  – dependem de uma bateria
  – armazenam rel´gio e configura¸oes
                 o              c˜
Monoprograma¸˜o
                        ca
            0xFFF …
                      Operating           Device
                      system in       drivers in ROM
                        ROM
  User
program                                    User
                                         program
                        User
                      program
Operating                               Operating
system in                               system in
  RAM                                     RAM
            0                     0                    0
   (a)                   (b)               (c)

mainframes            palmtops         MS-DOS
Multiprograma¸˜o e parti¸oes fixas
             ca         c˜
   Multiple
input queues
                             800K
               Partition 4                        Partition 4
                             700K


               Partition 3             Single     Partition 3
                                    input queue


                             400K

               Partition 2                        Partition 2

                             200K
               Partition 1                        Partition 1
                             100K
               Operating                          Operating
                system                             system
                             0
                   (a)                                (b)
Modelagem de multiprograma¸˜o
                           ca

• Quantos processos colocar na mem´ria?
                                  o
• Estimativa de uso da CPU

                                      20% I/O Wait

                                      50% I/O Wait

                                      80% I/O Wait
Modelagem de multiprograma¸˜o
                           ca
• Quantos processos colocar na mem´ria?
                                  o
• Aposta otimista: 5 processos 80
Modelagem de multiprograma¸˜o
                           ca
• Vis˜o probabil´
     a          ıstica
• Taxa de utiliza¸˜o da CPU = 1 - (0.8)n
                 ca

  ...

  ...

  ...

  ...

  ...
Modelagem de multiprograma¸˜o
                          ca
                                                   20% I/O wait
CPU utilization (in percent)


                               100
                                                         50% I/O wait
                               80

                               60                             80% I/O wait

                               40

                               20


                                     0   1     2     3      4    5     6     7   8    9   10
                                                         Degree of multiprogramming
                                             Utiliza¸˜o da CPU = 1 - p
                                                    ca                          n
An´lise de Desempenho
                a
                         CPU
              Arrival   minutes                                               # Processes
        Job    time     needed                                              1    2    3   4
         1    10:00        4                              CPU idle         .80     .64      .51   .41
         2    10:10        3                              CPU busy         .20     .36      .49   .59
        3     10:15          2                            CPU/process      .20     .18      .16   .15
        4     10:20          2
                (a)                                                                 (b)



                2.0                       .9              .8      .3             Job 1 finishes
1
              Job 2 starts                .9              .8      .3              .9         .1
2
                                                          .8      .3              .9
3
                                                                  .3              .9         .1       .7
4

0
    0                            10              15              20 22                    27.6 28.2        31.7
                                      Time (relative to job 1's arrival)
                                                    (c)
Swapping
                                 CPU



                                         CPU scheduler


Arriving
  job
            Input
           queue
                                 Main
                                Memory




                                                  Memory     Disk
                    Admission
                    scheduler                    scheduler
Swapping
                                    Time



                           C           C           C           C           C


               B           B           B           B
                                                                           A

   A           A           A
                                                   D           D           D

Operating   Operating   Operating   Operating   Operating   Operating   Operating
 system      system      system      system      system      system      system
   (a)         (b)         (c)         (d)         (e)         (f)         (g)
Reloca¸˜o e Prote¸˜o
                ca         ca
• Reloca¸˜o: um programa deve poder rodar em endere¸os
          ca                                       c
  f´
   ısicos distintos.
• Prote¸˜o: um programa n˜o pode fazer acesso ` ´rea de
       ca                 a                   aa
  mem´ria reservada a outro programa.
      o
Reloca¸˜o durante a carga
             ca
• Todos os endere¸os precisam ser identificados e alterados
                 c
• N˜o resolve o problema da prote¸˜o
   a                             ca
Bits de prote¸˜o
                            ca
                      1010
                      1010
                      1010
                      0011
                      0011

O PSW de cada processo deve conter os bits de prote¸˜o
                                                   ca
Registradores base e limite
   Address
                                                            Registers
                                                              when
0xFFFFFFFF                                                  program 2
                                                            is running

                 User program   Registers
                                                               Limit-2
                   and data       when
                                program 1    User-2 data
                                is running                     Base-2


   Limit                        Limit-2
                 User program   Base-2       User-1 data
                   and data                                    Limit-1
                                Limit-1      User program
   Base                         Base-1                         Base-1




                  Operating                   Operating
                   System                      System
             0
                     (a)                         (b)
Espa¸o para crescimento
                c
                               B-Stack
            Room for growth
                                          Room for growth

                               B-Data
   B        Actually in use
                              B-Program



                               A-Stack
            Room for growth
                                          Room for growth           Address (hex)
                               A-Data                               FFFF
   A        Actually in use                                 Stack
                              A-Program
                                                            Gap
Operating                     Operating
 system                        system
                                                            Data

   (a)                           (b)                        Text
                                                                    0000
Compacta¸˜o de mem´ria
        ca        o

      A       A


      —       B
      B       C
      —       —
      C       —
Bitmaps e lista de livres
  A                   B          C                   D             E
              8                  16                       24
                                      (a)


11111000          P   0   5          H      5   3         P    8   6   P 14 4
11111111
11001111
                  H 18 2             P 20 6               P 26 3       H 29 3   X
11111000

            Hole Starts Length                       Process
                 at 18    2
   (b)                                              (c)
Atualiza¸˜o da lista
                   ca
      Before X terminates             After X terminates
(a)    A      X      B      becomes   A              B

(b)    A      X             becomes   A

(c)           X      B      becomes                  B

(d)           X             becomes
Algoritmos para aloca¸˜o de mem´ria
                     ca        o
• First fit
• Next fit
• Best fit
• Worst fit
Problema relacionado
               Malloc, free e realloc
       void *malloc(size_t size);
       void free(void *ptr);
       void *realloc(void *ptr, size_t size);
A aloca¸˜o de registros dentro de um processo tem
       ca
problemas semelhantes:
 • administra¸˜o de uma lista de livres
             ca
 • fragmenta¸˜o
            ca
Programas muito grandes
O que fazer se um programa for muito grande para caber na
mem´ria?
    o
Overlays
dados d1, d2, d3, d4, d5;

f1();    g1();    h1();
f2();    g2();    h2();
f3();    g3();    h3();

main() {
  fase_1();   /* fun¸oes f e dados d1, d2, d3 */
                    c
  fase_2();   /* fun¸oes g e dados d1, d2, d4 */
                    c
  fase_3();   /* fun¸oes h e dados d1, d2, d5 */
                    c
  }
Mem´ria Virtual
                 o
                    The CPU sends virtual
        CPU         addresses to the MMU
       package

CPU
                   Memory                     Disk
                  management     Memory     controller
                     unit



                                                         Bus

      The MMU sends physical
      addresses to the memory


        Memory Management Unit (MMU)
Pagina¸˜o
                 ca
 Virtual
address
  space
60K-64K     X
56K-60K    X    Virtual page
52K-56K    X
48K-52K    X
44K-48K    7
40K-44K    X
                               Physical
36K-40K    5                   memory
32K-36K    X                   address
28K-32K    X                   28K-32K
24K-28K    X                   24K-28K
20K-24K    3                   20K-24K
16K-20K    4                   16K-20K
12K-16K    0                   12K-16K
 8K-12K    6                   8K-12K
  4K-8K    1                   4K-8K
  0K-4K    2                      0K-4K

                               Page frame
Mapeamento dos endere¸os
                     c
                                                                 Outgoing
            1 1 0 0 0 0 0 0 0 0 0 0 1 0 0                        physical
                                                                 address
                                                                 (24580)

             15    000     0
             14    000     0
             13    000     0
             12    000     0
             11    111     1
             10    000     0
              9    101     1
                                               12-bit offset
  Page        8    000     0
                                               copied directly
  table       7    000     0                   from input
              6    000     0                   to output
              5    011     1
              4    100     1
              3    000     1
              2    110     1        110
              1    001     1
                                  Present/
              0    010     1
                                  absent bit
              Virtual page = 2 is used
              as an index into the
              page table                                         Incoming
                                                                 virtual
                                                                 address
          0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0
                                                                 (8196)
Espa¸o de endere¸amento
           c           c
• Apenas as p´ginas ocupadas precisam ser mapeadas
             a
                           Address (hex)
                           FFFF
                   Stack

                    Gap

                   Data
                    Text
                           0000
Mem´ria compartilhada
   o
    Processo A   Processo B

      Pilha        Pilha




                  Shmem

     Shmem


      Data         Data
      Texto        Texto
Mem´ria compartilhada
            o
  int shmget(key_t key, size_t size, int shmflg);
  void *shmat(int shmid,
              const void *shmaddr, int shmflg);
• Veja os exemplos: sh1.c sh2,c sh fork.c

Weitere ähnliche Inhalte

Andere mochten auch

Veiculoimaginario liquidos
Veiculoimaginario liquidosVeiculoimaginario liquidos
Veiculoimaginario liquidoslobisomem1973
 
07-08-2013 El Gobernador Guillermo Padrés colocó la primera piedra de Ellison...
07-08-2013 El Gobernador Guillermo Padrés colocó la primera piedra de Ellison...07-08-2013 El Gobernador Guillermo Padrés colocó la primera piedra de Ellison...
07-08-2013 El Gobernador Guillermo Padrés colocó la primera piedra de Ellison...Guillermo Padrés Elías
 
2011 RESIDENTIAL BUILDING DESIGN BROCHURE GD-INCO
2011 RESIDENTIAL BUILDING DESIGN BROCHURE GD-INCO2011 RESIDENTIAL BUILDING DESIGN BROCHURE GD-INCO
2011 RESIDENTIAL BUILDING DESIGN BROCHURE GD-INCOBIMGENIA S.L.
 
Soluções em dados geográficos
Soluções em dados geográficosSoluções em dados geográficos
Soluções em dados geográficosImagem Maps
 
Tabletas
TabletasTabletas
TabletasrafaU23
 
Incremental Subdivision for Triangle Meshes
Incremental Subdivision for Triangle MeshesIncremental Subdivision for Triangle Meshes
Incremental Subdivision for Triangle MeshesMichel Alves
 
Damien Piller - Migros Rapport Annuel
Damien Piller - Migros Rapport AnnuelDamien Piller - Migros Rapport Annuel
Damien Piller - Migros Rapport AnnuelDamien Piller
 
PortFolio AUg.Arquitectos, SLP
PortFolio AUg.Arquitectos, SLPPortFolio AUg.Arquitectos, SLP
PortFolio AUg.Arquitectos, SLPSalvador G.
 
Metro do Porto
Metro do PortoMetro do Porto
Metro do Portotomallen
 
Simbioses Industriais
Simbioses IndustriaisSimbioses Industriais
Simbioses IndustriaisInês Costa
 
Rapport d'activité annuel 2015. Médiathèque Agneaux
Rapport d'activité annuel 2015. Médiathèque AgneauxRapport d'activité annuel 2015. Médiathèque Agneaux
Rapport d'activité annuel 2015. Médiathèque AgneauxSylvie Cuesta
 
Fost Plus rapport annuel 2015
Fost Plus rapport annuel 2015Fost Plus rapport annuel 2015
Fost Plus rapport annuel 2015Kelly Baetens
 
Infnet Infra Day II - Server Core na prática
Infnet Infra Day II - Server Core na práticaInfnet Infra Day II - Server Core na prática
Infnet Infra Day II - Server Core na práticaInvent IT Solutions
 
Gehorthese
GehortheseGehorthese
Gehorthesemedentic
 
Introduction to Hardening: A Short Course
Introduction to Hardening: A Short CourseIntroduction to Hardening: A Short Course
Introduction to Hardening: A Short CourseMichel Alves
 

Andere mochten auch (20)

Veiculoimaginario liquidos
Veiculoimaginario liquidosVeiculoimaginario liquidos
Veiculoimaginario liquidos
 
Alias 2012 sales
Alias 2012 salesAlias 2012 sales
Alias 2012 sales
 
07-08-2013 El Gobernador Guillermo Padrés colocó la primera piedra de Ellison...
07-08-2013 El Gobernador Guillermo Padrés colocó la primera piedra de Ellison...07-08-2013 El Gobernador Guillermo Padrés colocó la primera piedra de Ellison...
07-08-2013 El Gobernador Guillermo Padrés colocó la primera piedra de Ellison...
 
Cenários de Mudanças Climáticas: Regionalização (‘downscaling’)
Cenários de Mudanças Climáticas: Regionalização (‘downscaling’)Cenários de Mudanças Climáticas: Regionalização (‘downscaling’)
Cenários de Mudanças Climáticas: Regionalização (‘downscaling’)
 
Microsoft surface
Microsoft surfaceMicrosoft surface
Microsoft surface
 
Tabletas electronicas sss
Tabletas electronicas sssTabletas electronicas sss
Tabletas electronicas sss
 
2011 RESIDENTIAL BUILDING DESIGN BROCHURE GD-INCO
2011 RESIDENTIAL BUILDING DESIGN BROCHURE GD-INCO2011 RESIDENTIAL BUILDING DESIGN BROCHURE GD-INCO
2011 RESIDENTIAL BUILDING DESIGN BROCHURE GD-INCO
 
Soluções em dados geográficos
Soluções em dados geográficosSoluções em dados geográficos
Soluções em dados geográficos
 
Tabletas
TabletasTabletas
Tabletas
 
Incremental Subdivision for Triangle Meshes
Incremental Subdivision for Triangle MeshesIncremental Subdivision for Triangle Meshes
Incremental Subdivision for Triangle Meshes
 
Damien Piller - Migros Rapport Annuel
Damien Piller - Migros Rapport AnnuelDamien Piller - Migros Rapport Annuel
Damien Piller - Migros Rapport Annuel
 
PortFolio AUg.Arquitectos, SLP
PortFolio AUg.Arquitectos, SLPPortFolio AUg.Arquitectos, SLP
PortFolio AUg.Arquitectos, SLP
 
Metro do Porto
Metro do PortoMetro do Porto
Metro do Porto
 
Simbioses Industriais
Simbioses IndustriaisSimbioses Industriais
Simbioses Industriais
 
Rapport d'activité annuel 2015. Médiathèque Agneaux
Rapport d'activité annuel 2015. Médiathèque AgneauxRapport d'activité annuel 2015. Médiathèque Agneaux
Rapport d'activité annuel 2015. Médiathèque Agneaux
 
Fost Plus rapport annuel 2015
Fost Plus rapport annuel 2015Fost Plus rapport annuel 2015
Fost Plus rapport annuel 2015
 
Infnet Infra Day II - Server Core na prática
Infnet Infra Day II - Server Core na práticaInfnet Infra Day II - Server Core na prática
Infnet Infra Day II - Server Core na prática
 
Gehorthese
GehortheseGehorthese
Gehorthese
 
Introduction to Hardening: A Short Course
Introduction to Hardening: A Short CourseIntroduction to Hardening: A Short Course
Introduction to Hardening: A Short Course
 
Modelagem Climática - Apresentação dos cenários IPCC AR4 e AR5 e consideraçõe...
Modelagem Climática - Apresentação dos cenários IPCC AR4 e AR5 e consideraçõe...Modelagem Climática - Apresentação dos cenários IPCC AR4 e AR5 e consideraçõe...
Modelagem Climática - Apresentação dos cenários IPCC AR4 e AR5 e consideraçõe...
 

Ähnlich wie Gerenciamento de Memória(2)

PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + MemcachedFord AntiTrust
 
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)Nate Lawson
 
BlueHat v18 || A mitigation for kernel toctou vulnerabilities
BlueHat v18 || A mitigation for kernel toctou vulnerabilitiesBlueHat v18 || A mitigation for kernel toctou vulnerabilities
BlueHat v18 || A mitigation for kernel toctou vulnerabilitiesBlueHat Security Conference
 
Bootloader and MMU (english)
Bootloader and MMU (english)Bootloader and MMU (english)
Bootloader and MMU (english)Sneeker Yeh
 
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...The Linux Foundation
 
USAA Mono-to-Serverless.pdf
USAA Mono-to-Serverless.pdfUSAA Mono-to-Serverless.pdf
USAA Mono-to-Serverless.pdfRichHagarty
 
PerfUG 3 - perfs système
PerfUG 3 - perfs systèmePerfUG 3 - perfs système
PerfUG 3 - perfs systèmeLudovic Piot
 
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for WindowsFord AntiTrust
 
Prezentácia Mac OS X Leopard
Prezentácia Mac OS X LeopardPrezentácia Mac OS X Leopard
Prezentácia Mac OS X Leopardonlinestore
 
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld
 
2020-ntn-vsphere_performance_principles_bondzio.pdf
2020-ntn-vsphere_performance_principles_bondzio.pdf2020-ntn-vsphere_performance_principles_bondzio.pdf
2020-ntn-vsphere_performance_principles_bondzio.pdfPhmNgcTr3
 
Virtual Machine Introspection with Xen
Virtual Machine Introspection with XenVirtual Machine Introspection with Xen
Virtual Machine Introspection with XenTamas K Lengyel
 
Spark Summit EU talk by Jorg Schad
Spark Summit EU talk by Jorg SchadSpark Summit EU talk by Jorg Schad
Spark Summit EU talk by Jorg SchadSpark Summit
 

Ähnlich wie Gerenciamento de Memória(2) (20)

Performance tuning on the blackfin Processor
Performance tuning  on the blackfin ProcessorPerformance tuning  on the blackfin Processor
Performance tuning on the blackfin Processor
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
 
VDI Design Guide
VDI Design GuideVDI Design Guide
VDI Design Guide
 
Implementing Lightweight Networking
Implementing Lightweight NetworkingImplementing Lightweight Networking
Implementing Lightweight Networking
 
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
 
Ibm cell
Ibm cell Ibm cell
Ibm cell
 
XS Boston 2008 OpenSolaris
XS Boston 2008 OpenSolarisXS Boston 2008 OpenSolaris
XS Boston 2008 OpenSolaris
 
Chap4
Chap4 Chap4
Chap4
 
MySQL Tuning
MySQL TuningMySQL Tuning
MySQL Tuning
 
BlueHat v18 || A mitigation for kernel toctou vulnerabilities
BlueHat v18 || A mitigation for kernel toctou vulnerabilitiesBlueHat v18 || A mitigation for kernel toctou vulnerabilities
BlueHat v18 || A mitigation for kernel toctou vulnerabilities
 
Bootloader and MMU (english)
Bootloader and MMU (english)Bootloader and MMU (english)
Bootloader and MMU (english)
 
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
 
USAA Mono-to-Serverless.pdf
USAA Mono-to-Serverless.pdfUSAA Mono-to-Serverless.pdf
USAA Mono-to-Serverless.pdf
 
PerfUG 3 - perfs système
PerfUG 3 - perfs systèmePerfUG 3 - perfs système
PerfUG 3 - perfs système
 
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
 
Prezentácia Mac OS X Leopard
Prezentácia Mac OS X LeopardPrezentácia Mac OS X Leopard
Prezentácia Mac OS X Leopard
 
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines VMworld 2013: Extreme Performance Series: Monster Virtual Machines
VMworld 2013: Extreme Performance Series: Monster Virtual Machines
 
2020-ntn-vsphere_performance_principles_bondzio.pdf
2020-ntn-vsphere_performance_principles_bondzio.pdf2020-ntn-vsphere_performance_principles_bondzio.pdf
2020-ntn-vsphere_performance_principles_bondzio.pdf
 
Virtual Machine Introspection with Xen
Virtual Machine Introspection with XenVirtual Machine Introspection with Xen
Virtual Machine Introspection with Xen
 
Spark Summit EU talk by Jorg Schad
Spark Summit EU talk by Jorg SchadSpark Summit EU talk by Jorg Schad
Spark Summit EU talk by Jorg Schad
 

Mehr von elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 

Mehr von elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Kürzlich hochgeladen

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Gerenciamento de Memória(2)

  • 2. Sonho dos usu´rios a Idealmente, a mem´ria deveria ser o • r´pida, a • de custo baixo, • imensa e • n˜o vol´til. a a
  • 3. Realidade para os usu´rios a Hierarquia de Mem´ria o Typical access time Typical capacity 1 nsec Registers <1 KB 2 nsec Cache 1 MB 10 nsec Main memory 64-512 MB 10 msec Magnetic disk 5-50 GB 100 sec Magnetic tape 20-100 GB
  • 4. Hierarquia de Mem´ria o Registradores • Internos ` CPU a • Extremamente r´pidos a • Otimiza¸oes de c´digo podem mover temporariamente c˜ o vari´veis para registradores. a • Programas podem dar palpites sobre o que deve ficar armazenado nos registradores register int r;
  • 5. Hierarquia de Mem´ria o Cache • Internos ou muito pr´ximos ` CPU o a • Divididos em linhas de cache • Controlados por hardware • Cache hit • Cache miss
  • 6. Hierarquia de Mem´ria o Mem´ria Principal o • Random Access Memory (RAM) • Compromisso entre pre¸o e desempenho c • Armazenamento vol´til a
  • 7. Hierarquia de Mem´ria o Disco Read/write head (1 per surface) Surface 7 Surface 6 Surface 5 Surface 4 Surface 3 Direction of arm motion Surface 2 Surface 1 Surface 0
  • 8. Hierarquia de Mem´ria o Fitas magn´ticas e • Utilizadas para c´pias de seguran¸a (backups) o c • Armazenamento de grandes quantidades de dados • Acesso seq¨encial u
  • 9. Hierarquia de Mem´ria o Outros tipos de mem´ria o • ROM (Read Only Memory) – r´pida e barata a – bootstrap loader est´ gravado em ROM a • EEPROM (Electrically Erasable ROM) – podem ser apagadas (erros podem ser corrigidos) • CMOS – dependem de uma bateria – armazenam rel´gio e configura¸oes o c˜
  • 10. Monoprograma¸˜o ca 0xFFF … Operating Device system in drivers in ROM ROM User program User program User program Operating Operating system in system in RAM RAM 0 0 0 (a) (b) (c) mainframes palmtops MS-DOS
  • 11. Multiprograma¸˜o e parti¸oes fixas ca c˜ Multiple input queues 800K Partition 4 Partition 4 700K Partition 3 Single Partition 3 input queue 400K Partition 2 Partition 2 200K Partition 1 Partition 1 100K Operating Operating system system 0 (a) (b)
  • 12. Modelagem de multiprograma¸˜o ca • Quantos processos colocar na mem´ria? o • Estimativa de uso da CPU 20% I/O Wait 50% I/O Wait 80% I/O Wait
  • 13. Modelagem de multiprograma¸˜o ca • Quantos processos colocar na mem´ria? o • Aposta otimista: 5 processos 80
  • 14. Modelagem de multiprograma¸˜o ca • Vis˜o probabil´ a ıstica • Taxa de utiliza¸˜o da CPU = 1 - (0.8)n ca ... ... ... ... ...
  • 15. Modelagem de multiprograma¸˜o ca 20% I/O wait CPU utilization (in percent) 100 50% I/O wait 80 60 80% I/O wait 40 20 0 1 2 3 4 5 6 7 8 9 10 Degree of multiprogramming Utiliza¸˜o da CPU = 1 - p ca n
  • 16. An´lise de Desempenho a CPU Arrival minutes # Processes Job time needed 1 2 3 4 1 10:00 4 CPU idle .80 .64 .51 .41 2 10:10 3 CPU busy .20 .36 .49 .59 3 10:15 2 CPU/process .20 .18 .16 .15 4 10:20 2 (a) (b) 2.0 .9 .8 .3 Job 1 finishes 1 Job 2 starts .9 .8 .3 .9 .1 2 .8 .3 .9 3 .3 .9 .1 .7 4 0 0 10 15 20 22 27.6 28.2 31.7 Time (relative to job 1's arrival) (c)
  • 17. Swapping CPU CPU scheduler Arriving job Input queue Main Memory Memory Disk Admission scheduler scheduler
  • 18. Swapping Time C C C C C B B B B A A A A D D D Operating Operating Operating Operating Operating Operating Operating system system system system system system system (a) (b) (c) (d) (e) (f) (g)
  • 19. Reloca¸˜o e Prote¸˜o ca ca • Reloca¸˜o: um programa deve poder rodar em endere¸os ca c f´ ısicos distintos. • Prote¸˜o: um programa n˜o pode fazer acesso ` ´rea de ca a aa mem´ria reservada a outro programa. o
  • 20. Reloca¸˜o durante a carga ca • Todos os endere¸os precisam ser identificados e alterados c • N˜o resolve o problema da prote¸˜o a ca
  • 21. Bits de prote¸˜o ca 1010 1010 1010 0011 0011 O PSW de cada processo deve conter os bits de prote¸˜o ca
  • 22. Registradores base e limite Address Registers when 0xFFFFFFFF program 2 is running User program Registers Limit-2 and data when program 1 User-2 data is running Base-2 Limit Limit-2 User program Base-2 User-1 data and data Limit-1 Limit-1 User program Base Base-1 Base-1 Operating Operating System System 0 (a) (b)
  • 23. Espa¸o para crescimento c B-Stack Room for growth Room for growth B-Data B Actually in use B-Program A-Stack Room for growth Room for growth Address (hex) A-Data FFFF A Actually in use Stack A-Program Gap Operating Operating system system Data (a) (b) Text 0000
  • 24. Compacta¸˜o de mem´ria ca o A A — B B C — — C —
  • 25. Bitmaps e lista de livres A B C D E 8 16 24 (a) 11111000 P 0 5 H 5 3 P 8 6 P 14 4 11111111 11001111 H 18 2 P 20 6 P 26 3 H 29 3 X 11111000 Hole Starts Length Process at 18 2 (b) (c)
  • 26. Atualiza¸˜o da lista ca Before X terminates After X terminates (a) A X B becomes A B (b) A X becomes A (c) X B becomes B (d) X becomes
  • 27. Algoritmos para aloca¸˜o de mem´ria ca o • First fit • Next fit • Best fit • Worst fit
  • 28. Problema relacionado Malloc, free e realloc void *malloc(size_t size); void free(void *ptr); void *realloc(void *ptr, size_t size); A aloca¸˜o de registros dentro de um processo tem ca problemas semelhantes: • administra¸˜o de uma lista de livres ca • fragmenta¸˜o ca
  • 29. Programas muito grandes O que fazer se um programa for muito grande para caber na mem´ria? o
  • 30. Overlays dados d1, d2, d3, d4, d5; f1(); g1(); h1(); f2(); g2(); h2(); f3(); g3(); h3(); main() { fase_1(); /* fun¸oes f e dados d1, d2, d3 */ c fase_2(); /* fun¸oes g e dados d1, d2, d4 */ c fase_3(); /* fun¸oes h e dados d1, d2, d5 */ c }
  • 31. Mem´ria Virtual o The CPU sends virtual CPU addresses to the MMU package CPU Memory Disk management Memory controller unit Bus The MMU sends physical addresses to the memory Memory Management Unit (MMU)
  • 32. Pagina¸˜o ca Virtual address space 60K-64K X 56K-60K X Virtual page 52K-56K X 48K-52K X 44K-48K 7 40K-44K X Physical 36K-40K 5 memory 32K-36K X address 28K-32K X 28K-32K 24K-28K X 24K-28K 20K-24K 3 20K-24K 16K-20K 4 16K-20K 12K-16K 0 12K-16K 8K-12K 6 8K-12K 4K-8K 1 4K-8K 0K-4K 2 0K-4K Page frame
  • 33. Mapeamento dos endere¸os c Outgoing 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 physical address (24580) 15 000 0 14 000 0 13 000 0 12 000 0 11 111 1 10 000 0 9 101 1 12-bit offset Page 8 000 0 copied directly table 7 000 0 from input 6 000 0 to output 5 011 1 4 100 1 3 000 1 2 110 1 110 1 001 1 Present/ 0 010 1 absent bit Virtual page = 2 is used as an index into the page table Incoming virtual address 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 (8196)
  • 34. Espa¸o de endere¸amento c c • Apenas as p´ginas ocupadas precisam ser mapeadas a Address (hex) FFFF Stack Gap Data Text 0000
  • 35. Mem´ria compartilhada o Processo A Processo B Pilha Pilha Shmem Shmem Data Data Texto Texto
  • 36. Mem´ria compartilhada o int shmget(key_t key, size_t size, int shmflg); void *shmat(int shmid, const void *shmaddr, int shmflg); • Veja os exemplos: sh1.c sh2,c sh fork.c