SlideShare a Scribd company logo
1 of 38
Hilos
Capítulo 5
Silberschatz Galvin
Hilos2
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos
Concepto
Beneficios
Hilos a nivel kérnel y a nivel usuario
Modelos multihilos
Hilos de Solaris 2
Hilos de Java
Hilos3
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos
Un hilo (o proceso ligero) es una unidad básica de utilización
del CPU; consiste de:
• Contador de programa
• Conjunto de registros
• Espacio de stack
Hilos4
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos
Un hilo comparte con sus hilos pares:
• Sección de código
• Sección de datos
• Recursos del sistema operativo
• En conjunto se les conoce como tarea
Un proceso tradicional o pesado, es igual a una tarea con un
hilo.
Hilos5
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
un proceso
un hilo
varios procesos
un hilo por proceso
varios procesos
varios hilos por proceso
un proceso
varios hilos
Hilos y procesos
Hilos6
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Código Datos Archivos Código Datos Archivos
Hilo Hilos
Mono-hilo Multi-hilo
Procesos con un solo hilo y con múltiples
hilos
Hilos7
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Bloque de
control
del hilo
Stack
del
usuario
Stack
del
usuario
Stack
del
kernel
Stack
del
Kernel
Espacio de
direcciones
del usuario
Espacio de
direcciones
del usuario
Bloque de
control del
proceso
Bloque
de control
del proceso
Hilo
Modelo de proceso
de un solo hilo
Modelo de proceso
multihilos
Bloque de
control
del hilo
Stack
del
usuario
Stack
del
kernel
Hilo
Bloque de
control
del hilo
Stack
del
usuario
Stack
del
kernel
Hilo
Modelos de procesos de un solo hilo y de
muchos hilos
Hilos8
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Multihilo
Sistema operativo que mantiene varios hilos de ejecución
dentro de un mismo proceso.
MS-DOS soporta un solo hilo.
UNIX soporta múltiples procesos de usuarios, pero sólo un hilo
por proceso.
Windows 2000, Solaris, Linux, Mac OS, OS/2 soportan múltiples
hilos.
Hilos9
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos
En una tarea donde hay múltiples hilos, mientras un hilo
servidor está bloqueado y esperando, otro hilo en la misma
tarea puede ejecutarse.
• Cooperación de múltiples hilos en la misma tarea aumenta la
tasa de trabajos por unidad tiempo y mejora el rendimiento.
• Aplicaciones que requieren compartir un buffer común
(productor-consumidor) sacan provecho de la utilización de
hilos.
Hilos10
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos
Los hilos proveen un mecanismo que permiten a procesos
secuenciales hacer llamadas bloqueantes mientras otros en
paralelo ejecutan otras operaciones.
Hilos11
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Beneficios
Compartición de recursos
Economía
Utilización de arquitecturas de múltiples procesadores
Hilos12
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos a nivel usuario
El manejo de los hilos lo hace una librería de hilos a nivel
usuario
Ejemplos
- Hilos POSIX
- Mach C-threads
- Hilos de Solaris
Hilos13
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos a nivel usuario (un CPU con dos
núcleos)
Nivel kérnel
(sistema
operativo)
Nivel usuario
Proceso de usuario gestiona y
planifica los múltiples hilos
Core CoreCPU
Hardware
Planificador del SO
Hilos14
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Ventajas de los hilos a nivel usuario
Los hilos podían implementarse en las aplicaciones que se
ejecutaban en sistemas operativos que no son capaces de
planificar hilos
• Ejemplo: Primeras implementaciones de UNIX
Hilos15
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Desventajas de los hilos a nivel usuario
El planificador del sistema operativo solo ve un hilo por proceso
 No ve los hilos a nivel usuario
 Usa un solo núcleo del procesador en un procesador que tiene
más de un núcleo
 No puede distribuir los hilos a nivel el usuario en los dos
núcleos
Hilos16
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos a nivel kérnel
Soportados por el kérnel
Ejemplos
• Windows 95/98/NT
• Solaris
• Linux
• Mac OS
Hilos17
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos a nivel kernel (con un CPU con un solo
núcleo)
Nivel kérnel
(sistema
operativo)
Nivel usuario
CoreCPU
Hardware
Planificador del SO
Hilos18
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos a nivel kernel (con un CPU con doble
núcleo)
Nivel kérnel
(sistema
operativo)
Nivel usuario
Core CoreCPU
Hardware
Planificador del SO
Hilos19
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Ventajas de los hilos a nivel kérnel
El proceso de usuario no se tiene que encargar de la
planificación de los hilos
Si tenemos un procesador con más de un núcelo, el Sistema
operativo puede planificar los hilos en diferentes núcleos
Hilos20
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Modelos multihilos
Muchos a uno
Uno a uno
Muchos a muchos
Hilos21
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Muchos a uno
Muchos hilos a nivel usuario mapeados a un hilo a nivel kérnel.
Usado en sistemas que no soportan hilos a nivel kérnel.
Hilos22
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Modelo muchos a uno
kk
Hilos23
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
EjecuciónListo
Listo
Relaciones entre estados de ULTs y estados
de procesos
Ejecución
Bloqueado
Bloqueado
Listo Ejecución
Bloqueado
Hilo 1
Hilo 2
Proceso B
Kernel
Usuario
Hilos24
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Uno a uno
Cada hilo a nivel usuario corresponde a un hilo del kérnel.
Ejemplos:
- Windows 95/98/NT
- OS/2
Hilos25
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Modelo uno a uno
kk kk kk kk
Hilo a nivel usuario
Hilo a nivel kérnel
Hilos26
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Modelo muchos a muchos
kk kkkk
Hilo a nivel usuario
Hilo a nivel kérnel
Hilos27
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Soporte de hilos en Solaris 2
Solaris 2 es una versión de UNIX con soporte para hilos a nivel
kernel y a nivel usuario, procesamiento simétrico y planificación
en tiempo real.
Hilos28
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Soporte de hilos en Solaris 2
LWP – Nivel intermedio entre los hilos a nivel kernel y los hilos
a nivel usuario.
Hilos29
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos en Solaris 2. Recursos necesarios para
los tipos de hilos
Hilos del kernel
• Estructura de datos pequeña y un stack
• El intercambio de hilos no requiere cambiar la información del
acceso a memoria
• Cambios de hilos relativamente rápidos
Hilos30
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos en Solaris 2. Recursos necesarios para
los tipos de hilos
LWP
• PCB con datos de los registros
• Información sobre la memoria
• El intercambio entre LWP es relativamente lento
Hilos31
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos en Solaris 2. Recursos necesarios para
los tipos de hilos
Hilos a nivel usuario
• Solo requiere un stack y un contador de programa
• No involucrar al kernel significa un intercambio rápido
• El kernel solo ve los LWP que soporta los hilos a nivel usuario
Hilos32
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Usuario
Núcleo
Hardware
Biblioteca
de hilos
Hilo a nivel de
usuario
Hilo del núcleo Proceso ligero Procesador
LL L LL L L L L
L P
P P P P P
Proceso 1 Proceso 2 Proceso 3 Proceso 4 Proceso 5
Ejemplo de la arquitectura multihilo de
Solaris
Hilos33
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Gestión de hilos básica
Un hilo tiene :
• Un identificador (ID)
• Una pila
• Una prioridad de ejecución
• Una dirección de inicio de ejecución.
Hilos34
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Gestión de hilos básica
(POSIX)
Se dice que un hilo es dinámico si se puede crear en cualquier
instante durante la ejecución.
En POSIX :
• los hilos se crean dinámicamente con la función
pthread_create.
• pthread_exit termina el hilo que la invoca.
Hilos35
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Gestión de hilos básica (POSIX), ejemplo:
Programa que crea un hilo donde muestra el mensaje “Hola
Mundo”
Para compilar el programa :
• $ cc -D_REENTRANT thread2.c -o thread2 -lpthread
Hilos36
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
int main()
{
pthread_create(a_thread,funcion_hilo);
pthread_join(a_thread);
}
funcion_hilo()
{
…
}
Crea un hilo
nuevo
Espera a que
termine el hilo
creado
Hilo principal
Hilo creado con la llamada
pthread_create
Hilos37
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Gestión de hilos básica
(POSIX)
Pthread_join()
• Hilo que ejecuta pthread_join, espera a que termine otro hilo
El hilo principal debe esperar a que terminen todos los hilos
creados
• Si el hilo principal no espera a que terminen los hilos creados,
al terminar termina el proceso con todos los hilos.
Hilos38
Copyright © 2006, Intel Corporation. All rights reserved.
Sistemas Operativos
Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners.
Hilos en memoria
Código
(compartido)
Datos
(compartidos)
Int cont=0 (var. Global)
Stack (de cada hilo)
Int i
(var local)
Stack (de cada hilo)
Int i
(var local)

More Related Content

What's hot

喬叔 Elasticsearch Index 管理技巧與效能優化
喬叔 Elasticsearch Index 管理技巧與效能優化喬叔 Elasticsearch Index 管理技巧與效能優化
喬叔 Elasticsearch Index 管理技巧與效能優化Joe Wu
 
Contrail Deep-dive - Cloud Network Services at Scale
Contrail Deep-dive - Cloud Network Services at ScaleContrail Deep-dive - Cloud Network Services at Scale
Contrail Deep-dive - Cloud Network Services at ScaleMarketingArrowECS_CZ
 
Continuous Go Profiling & Observability
Continuous Go Profiling & ObservabilityContinuous Go Profiling & Observability
Continuous Go Profiling & ObservabilityScyllaDB
 
Use case and integration of ClickHouse with Apache Superset & Dremio
Use case and integration of ClickHouse with Apache Superset & DremioUse case and integration of ClickHouse with Apache Superset & Dremio
Use case and integration of ClickHouse with Apache Superset & DremioAltinity Ltd
 
Deploying IPv6 in OpenStack Environments
Deploying IPv6 in OpenStack EnvironmentsDeploying IPv6 in OpenStack Environments
Deploying IPv6 in OpenStack EnvironmentsShannon McFarland
 
Mahout資料分析基礎入門
Mahout資料分析基礎入門Mahout資料分析基礎入門
Mahout資料分析基礎入門Jhang Raymond
 
YARN Ready: Integrating to YARN with Tez
YARN Ready: Integrating to YARN with Tez YARN Ready: Integrating to YARN with Tez
YARN Ready: Integrating to YARN with Tez Hortonworks
 
How to Extend Apache Spark with Customized Optimizations
How to Extend Apache Spark with Customized OptimizationsHow to Extend Apache Spark with Customized Optimizations
How to Extend Apache Spark with Customized OptimizationsDatabricks
 

What's hot (9)

喬叔 Elasticsearch Index 管理技巧與效能優化
喬叔 Elasticsearch Index 管理技巧與效能優化喬叔 Elasticsearch Index 管理技巧與效能優化
喬叔 Elasticsearch Index 管理技巧與效能優化
 
Contrail Deep-dive - Cloud Network Services at Scale
Contrail Deep-dive - Cloud Network Services at ScaleContrail Deep-dive - Cloud Network Services at Scale
Contrail Deep-dive - Cloud Network Services at Scale
 
Continuous Go Profiling & Observability
Continuous Go Profiling & ObservabilityContinuous Go Profiling & Observability
Continuous Go Profiling & Observability
 
Use case and integration of ClickHouse with Apache Superset & Dremio
Use case and integration of ClickHouse with Apache Superset & DremioUse case and integration of ClickHouse with Apache Superset & Dremio
Use case and integration of ClickHouse with Apache Superset & Dremio
 
Deploying IPv6 in OpenStack Environments
Deploying IPv6 in OpenStack EnvironmentsDeploying IPv6 in OpenStack Environments
Deploying IPv6 in OpenStack Environments
 
Mahout資料分析基礎入門
Mahout資料分析基礎入門Mahout資料分析基礎入門
Mahout資料分析基礎入門
 
Nifi workshop
Nifi workshopNifi workshop
Nifi workshop
 
YARN Ready: Integrating to YARN with Tez
YARN Ready: Integrating to YARN with Tez YARN Ready: Integrating to YARN with Tez
YARN Ready: Integrating to YARN with Tez
 
How to Extend Apache Spark with Customized Optimizations
How to Extend Apache Spark with Customized OptimizationsHow to Extend Apache Spark with Customized Optimizations
How to Extend Apache Spark with Customized Optimizations
 

Similar to Understanding Threads in Operating Systems

Intel® Trace Analyzer e Collector (ITAC) - Intel Software Conference 2013
Intel® Trace Analyzer e Collector (ITAC) - Intel Software Conference 2013Intel® Trace Analyzer e Collector (ITAC) - Intel Software Conference 2013
Intel® Trace Analyzer e Collector (ITAC) - Intel Software Conference 2013Intel Software Brasil
 
Features of modern intel microprocessors
Features of modern intel microprocessorsFeatures of modern intel microprocessors
Features of modern intel microprocessorsKrunal Siddhapathak
 
17294_HiperSockets.pdf
17294_HiperSockets.pdf17294_HiperSockets.pdf
17294_HiperSockets.pdfEeszt
 
Introduction ciot workshop premeetup
Introduction ciot workshop premeetupIntroduction ciot workshop premeetup
Introduction ciot workshop premeetupBeMyApp
 
Intel® MPI Library e OpenMP* - Intel Software Conference 2013
Intel® MPI Library e OpenMP* - Intel Software Conference 2013Intel® MPI Library e OpenMP* - Intel Software Conference 2013
Intel® MPI Library e OpenMP* - Intel Software Conference 2013Intel Software Brasil
 
Linux on Z13 and Simulatenus Multithreading - Sebastien Llaurency
Linux on Z13 and Simulatenus Multithreading - Sebastien LlaurencyLinux on Z13 and Simulatenus Multithreading - Sebastien Llaurency
Linux on Z13 and Simulatenus Multithreading - Sebastien LlaurencyNRB
 
Intel Technologies for High Performance Computing
Intel Technologies for High Performance ComputingIntel Technologies for High Performance Computing
Intel Technologies for High Performance ComputingIntel Software Brasil
 
Intel® VTune™ Amplifier - Intel Software Conference 2013
Intel® VTune™ Amplifier - Intel Software Conference 2013Intel® VTune™ Amplifier - Intel Software Conference 2013
Intel® VTune™ Amplifier - Intel Software Conference 2013Intel Software Brasil
 
Apache HDFS Extended Attributes and Transparent Encryption
Apache HDFS Extended Attributes and Transparent EncryptionApache HDFS Extended Attributes and Transparent Encryption
Apache HDFS Extended Attributes and Transparent EncryptionUma Maheswara Rao Gangumalla
 
NFF-GO (YANFF) - Yet Another Network Function Framework
NFF-GO (YANFF) - Yet Another Network Function FrameworkNFF-GO (YANFF) - Yet Another Network Function Framework
NFF-GO (YANFF) - Yet Another Network Function FrameworkMichelle Holley
 
Using JavaScript to Build HTML5 Tools (Ian Maffett)
Using JavaScript to Build HTML5 Tools (Ian Maffett)Using JavaScript to Build HTML5 Tools (Ian Maffett)
Using JavaScript to Build HTML5 Tools (Ian Maffett)Future Insights
 
What are latest new features that DPDK brings into 2018?
What are latest new features that DPDK brings into 2018?What are latest new features that DPDK brings into 2018?
What are latest new features that DPDK brings into 2018?Michelle Holley
 
Intel XDK - Philly JS
Intel XDK - Philly JSIntel XDK - Philly JS
Intel XDK - Philly JSIan Maffett
 
Intel NFVi Enabling Kit Demo/Lab
Intel NFVi Enabling Kit Demo/LabIntel NFVi Enabling Kit Demo/Lab
Intel NFVi Enabling Kit Demo/LabMichelle Holley
 
OpenStack and z/VM – What is it and how do I get it?
OpenStack and z/VM – What is it and how do I get it?OpenStack and z/VM – What is it and how do I get it?
OpenStack and z/VM – What is it and how do I get it?Anderson Bassani
 
Methods and practices to analyze the performance of your application with Int...
Methods and practices to analyze the performance of your application with Int...Methods and practices to analyze the performance of your application with Int...
Methods and practices to analyze the performance of your application with Int...Intel Software Brasil
 
Cots moves to multicore: Wind River
Cots moves to multicore: Wind RiverCots moves to multicore: Wind River
Cots moves to multicore: Wind RiverKonrad Witte
 
Embree Ray Tracing Kernels
Embree Ray Tracing KernelsEmbree Ray Tracing Kernels
Embree Ray Tracing KernelsIntel® Software
 
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...Intel® Software
 

Similar to Understanding Threads in Operating Systems (20)

Intel® Trace Analyzer e Collector (ITAC) - Intel Software Conference 2013
Intel® Trace Analyzer e Collector (ITAC) - Intel Software Conference 2013Intel® Trace Analyzer e Collector (ITAC) - Intel Software Conference 2013
Intel® Trace Analyzer e Collector (ITAC) - Intel Software Conference 2013
 
Features of modern intel microprocessors
Features of modern intel microprocessorsFeatures of modern intel microprocessors
Features of modern intel microprocessors
 
17294_HiperSockets.pdf
17294_HiperSockets.pdf17294_HiperSockets.pdf
17294_HiperSockets.pdf
 
Introduction ciot workshop premeetup
Introduction ciot workshop premeetupIntroduction ciot workshop premeetup
Introduction ciot workshop premeetup
 
Intel® MPI Library e OpenMP* - Intel Software Conference 2013
Intel® MPI Library e OpenMP* - Intel Software Conference 2013Intel® MPI Library e OpenMP* - Intel Software Conference 2013
Intel® MPI Library e OpenMP* - Intel Software Conference 2013
 
Linux on Z13 and Simulatenus Multithreading - Sebastien Llaurency
Linux on Z13 and Simulatenus Multithreading - Sebastien LlaurencyLinux on Z13 and Simulatenus Multithreading - Sebastien Llaurency
Linux on Z13 and Simulatenus Multithreading - Sebastien Llaurency
 
Intel Technologies for High Performance Computing
Intel Technologies for High Performance ComputingIntel Technologies for High Performance Computing
Intel Technologies for High Performance Computing
 
Intel® VTune™ Amplifier - Intel Software Conference 2013
Intel® VTune™ Amplifier - Intel Software Conference 2013Intel® VTune™ Amplifier - Intel Software Conference 2013
Intel® VTune™ Amplifier - Intel Software Conference 2013
 
Apache HDFS Extended Attributes and Transparent Encryption
Apache HDFS Extended Attributes and Transparent EncryptionApache HDFS Extended Attributes and Transparent Encryption
Apache HDFS Extended Attributes and Transparent Encryption
 
NFF-GO (YANFF) - Yet Another Network Function Framework
NFF-GO (YANFF) - Yet Another Network Function FrameworkNFF-GO (YANFF) - Yet Another Network Function Framework
NFF-GO (YANFF) - Yet Another Network Function Framework
 
Using JavaScript to Build HTML5 Tools (Ian Maffett)
Using JavaScript to Build HTML5 Tools (Ian Maffett)Using JavaScript to Build HTML5 Tools (Ian Maffett)
Using JavaScript to Build HTML5 Tools (Ian Maffett)
 
What are latest new features that DPDK brings into 2018?
What are latest new features that DPDK brings into 2018?What are latest new features that DPDK brings into 2018?
What are latest new features that DPDK brings into 2018?
 
Intel XDK - Philly JS
Intel XDK - Philly JSIntel XDK - Philly JS
Intel XDK - Philly JS
 
Intel NFVi Enabling Kit Demo/Lab
Intel NFVi Enabling Kit Demo/LabIntel NFVi Enabling Kit Demo/Lab
Intel NFVi Enabling Kit Demo/Lab
 
Intel tools to optimize HPC systems
Intel tools to optimize HPC systemsIntel tools to optimize HPC systems
Intel tools to optimize HPC systems
 
OpenStack and z/VM – What is it and how do I get it?
OpenStack and z/VM – What is it and how do I get it?OpenStack and z/VM – What is it and how do I get it?
OpenStack and z/VM – What is it and how do I get it?
 
Methods and practices to analyze the performance of your application with Int...
Methods and practices to analyze the performance of your application with Int...Methods and practices to analyze the performance of your application with Int...
Methods and practices to analyze the performance of your application with Int...
 
Cots moves to multicore: Wind River
Cots moves to multicore: Wind RiverCots moves to multicore: Wind River
Cots moves to multicore: Wind River
 
Embree Ray Tracing Kernels
Embree Ray Tracing KernelsEmbree Ray Tracing Kernels
Embree Ray Tracing Kernels
 
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
 

More from Ichinose 11

Mapa mental gilberto ramos itdo acosta_erik solis
Mapa mental gilberto ramos itdo acosta_erik solisMapa mental gilberto ramos itdo acosta_erik solis
Mapa mental gilberto ramos itdo acosta_erik solisIchinose 11
 
Laboratorio n4 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n4 sistemas_operativos_gilberto_ramos_9-748-1883Laboratorio n4 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n4 sistemas_operativos_gilberto_ramos_9-748-1883Ichinose 11
 
Laboratorio n3 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n3 sistemas_operativos_gilberto_ramos_9-748-1883Laboratorio n3 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n3 sistemas_operativos_gilberto_ramos_9-748-1883Ichinose 11
 
Laboratorio#2 sistemas operativos gilberto ramos..
Laboratorio#2 sistemas operativos gilberto ramos..Laboratorio#2 sistemas operativos gilberto ramos..
Laboratorio#2 sistemas operativos gilberto ramos..Ichinose 11
 
Laboratorio n1 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n1 sistemas_operativos_gilberto_ramos_9-748-1883 Laboratorio n1 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n1 sistemas_operativos_gilberto_ramos_9-748-1883 Ichinose 11
 
Sistema compañeros
Sistema         compañerosSistema         compañeros
Sistema compañerosIchinose 11
 
Presentacion memoria
Presentacion memoriaPresentacion memoria
Presentacion memoriaIchinose 11
 
Sincronización entre procesos
Sincronización entre procesosSincronización entre procesos
Sincronización entre procesosIchinose 11
 

More from Ichinose 11 (12)

Mapa mental gilberto ramos itdo acosta_erik solis
Mapa mental gilberto ramos itdo acosta_erik solisMapa mental gilberto ramos itdo acosta_erik solis
Mapa mental gilberto ramos itdo acosta_erik solis
 
Laboratorio n4 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n4 sistemas_operativos_gilberto_ramos_9-748-1883Laboratorio n4 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n4 sistemas_operativos_gilberto_ramos_9-748-1883
 
Laboratorio n3 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n3 sistemas_operativos_gilberto_ramos_9-748-1883Laboratorio n3 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n3 sistemas_operativos_gilberto_ramos_9-748-1883
 
Laboratorio#2 sistemas operativos gilberto ramos..
Laboratorio#2 sistemas operativos gilberto ramos..Laboratorio#2 sistemas operativos gilberto ramos..
Laboratorio#2 sistemas operativos gilberto ramos..
 
Laboratorio n1 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n1 sistemas_operativos_gilberto_ramos_9-748-1883 Laboratorio n1 sistemas_operativos_gilberto_ramos_9-748-1883
Laboratorio n1 sistemas_operativos_gilberto_ramos_9-748-1883
 
Ubuntu touch
Ubuntu  touchUbuntu  touch
Ubuntu touch
 
Sistema compañeros
Sistema         compañerosSistema         compañeros
Sistema compañeros
 
Archivos 2016
Archivos 2016Archivos 2016
Archivos 2016
 
Bloqueos _
Bloqueos _Bloqueos _
Bloqueos _
 
Presentacion memoria
Presentacion memoriaPresentacion memoria
Presentacion memoria
 
Memoria 3
Memoria 3Memoria 3
Memoria 3
 
Sincronización entre procesos
Sincronización entre procesosSincronización entre procesos
Sincronización entre procesos
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 

Understanding Threads in Operating Systems

  • 2. Hilos2 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos Concepto Beneficios Hilos a nivel kérnel y a nivel usuario Modelos multihilos Hilos de Solaris 2 Hilos de Java
  • 3. Hilos3 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos Un hilo (o proceso ligero) es una unidad básica de utilización del CPU; consiste de: • Contador de programa • Conjunto de registros • Espacio de stack
  • 4. Hilos4 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos Un hilo comparte con sus hilos pares: • Sección de código • Sección de datos • Recursos del sistema operativo • En conjunto se les conoce como tarea Un proceso tradicional o pesado, es igual a una tarea con un hilo.
  • 5. Hilos5 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. un proceso un hilo varios procesos un hilo por proceso varios procesos varios hilos por proceso un proceso varios hilos Hilos y procesos
  • 6. Hilos6 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Código Datos Archivos Código Datos Archivos Hilo Hilos Mono-hilo Multi-hilo Procesos con un solo hilo y con múltiples hilos
  • 7. Hilos7 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Bloque de control del hilo Stack del usuario Stack del usuario Stack del kernel Stack del Kernel Espacio de direcciones del usuario Espacio de direcciones del usuario Bloque de control del proceso Bloque de control del proceso Hilo Modelo de proceso de un solo hilo Modelo de proceso multihilos Bloque de control del hilo Stack del usuario Stack del kernel Hilo Bloque de control del hilo Stack del usuario Stack del kernel Hilo Modelos de procesos de un solo hilo y de muchos hilos
  • 8. Hilos8 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Multihilo Sistema operativo que mantiene varios hilos de ejecución dentro de un mismo proceso. MS-DOS soporta un solo hilo. UNIX soporta múltiples procesos de usuarios, pero sólo un hilo por proceso. Windows 2000, Solaris, Linux, Mac OS, OS/2 soportan múltiples hilos.
  • 9. Hilos9 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos En una tarea donde hay múltiples hilos, mientras un hilo servidor está bloqueado y esperando, otro hilo en la misma tarea puede ejecutarse. • Cooperación de múltiples hilos en la misma tarea aumenta la tasa de trabajos por unidad tiempo y mejora el rendimiento. • Aplicaciones que requieren compartir un buffer común (productor-consumidor) sacan provecho de la utilización de hilos.
  • 10. Hilos10 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos Los hilos proveen un mecanismo que permiten a procesos secuenciales hacer llamadas bloqueantes mientras otros en paralelo ejecutan otras operaciones.
  • 11. Hilos11 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Beneficios Compartición de recursos Economía Utilización de arquitecturas de múltiples procesadores
  • 12. Hilos12 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos a nivel usuario El manejo de los hilos lo hace una librería de hilos a nivel usuario Ejemplos - Hilos POSIX - Mach C-threads - Hilos de Solaris
  • 13. Hilos13 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos a nivel usuario (un CPU con dos núcleos) Nivel kérnel (sistema operativo) Nivel usuario Proceso de usuario gestiona y planifica los múltiples hilos Core CoreCPU Hardware Planificador del SO
  • 14. Hilos14 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Ventajas de los hilos a nivel usuario Los hilos podían implementarse en las aplicaciones que se ejecutaban en sistemas operativos que no son capaces de planificar hilos • Ejemplo: Primeras implementaciones de UNIX
  • 15. Hilos15 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Desventajas de los hilos a nivel usuario El planificador del sistema operativo solo ve un hilo por proceso  No ve los hilos a nivel usuario  Usa un solo núcleo del procesador en un procesador que tiene más de un núcleo  No puede distribuir los hilos a nivel el usuario en los dos núcleos
  • 16. Hilos16 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos a nivel kérnel Soportados por el kérnel Ejemplos • Windows 95/98/NT • Solaris • Linux • Mac OS
  • 17. Hilos17 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos a nivel kernel (con un CPU con un solo núcleo) Nivel kérnel (sistema operativo) Nivel usuario CoreCPU Hardware Planificador del SO
  • 18. Hilos18 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos a nivel kernel (con un CPU con doble núcleo) Nivel kérnel (sistema operativo) Nivel usuario Core CoreCPU Hardware Planificador del SO
  • 19. Hilos19 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Ventajas de los hilos a nivel kérnel El proceso de usuario no se tiene que encargar de la planificación de los hilos Si tenemos un procesador con más de un núcelo, el Sistema operativo puede planificar los hilos en diferentes núcleos
  • 20. Hilos20 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Modelos multihilos Muchos a uno Uno a uno Muchos a muchos
  • 21. Hilos21 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Muchos a uno Muchos hilos a nivel usuario mapeados a un hilo a nivel kérnel. Usado en sistemas que no soportan hilos a nivel kérnel.
  • 22. Hilos22 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Modelo muchos a uno kk
  • 23. Hilos23 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. EjecuciónListo Listo Relaciones entre estados de ULTs y estados de procesos Ejecución Bloqueado Bloqueado Listo Ejecución Bloqueado Hilo 1 Hilo 2 Proceso B Kernel Usuario
  • 24. Hilos24 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Uno a uno Cada hilo a nivel usuario corresponde a un hilo del kérnel. Ejemplos: - Windows 95/98/NT - OS/2
  • 25. Hilos25 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Modelo uno a uno kk kk kk kk Hilo a nivel usuario Hilo a nivel kérnel
  • 26. Hilos26 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Modelo muchos a muchos kk kkkk Hilo a nivel usuario Hilo a nivel kérnel
  • 27. Hilos27 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Soporte de hilos en Solaris 2 Solaris 2 es una versión de UNIX con soporte para hilos a nivel kernel y a nivel usuario, procesamiento simétrico y planificación en tiempo real.
  • 28. Hilos28 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Soporte de hilos en Solaris 2 LWP – Nivel intermedio entre los hilos a nivel kernel y los hilos a nivel usuario.
  • 29. Hilos29 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos en Solaris 2. Recursos necesarios para los tipos de hilos Hilos del kernel • Estructura de datos pequeña y un stack • El intercambio de hilos no requiere cambiar la información del acceso a memoria • Cambios de hilos relativamente rápidos
  • 30. Hilos30 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos en Solaris 2. Recursos necesarios para los tipos de hilos LWP • PCB con datos de los registros • Información sobre la memoria • El intercambio entre LWP es relativamente lento
  • 31. Hilos31 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos en Solaris 2. Recursos necesarios para los tipos de hilos Hilos a nivel usuario • Solo requiere un stack y un contador de programa • No involucrar al kernel significa un intercambio rápido • El kernel solo ve los LWP que soporta los hilos a nivel usuario
  • 32. Hilos32 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Usuario Núcleo Hardware Biblioteca de hilos Hilo a nivel de usuario Hilo del núcleo Proceso ligero Procesador LL L LL L L L L L P P P P P P Proceso 1 Proceso 2 Proceso 3 Proceso 4 Proceso 5 Ejemplo de la arquitectura multihilo de Solaris
  • 33. Hilos33 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Gestión de hilos básica Un hilo tiene : • Un identificador (ID) • Una pila • Una prioridad de ejecución • Una dirección de inicio de ejecución.
  • 34. Hilos34 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Gestión de hilos básica (POSIX) Se dice que un hilo es dinámico si se puede crear en cualquier instante durante la ejecución. En POSIX : • los hilos se crean dinámicamente con la función pthread_create. • pthread_exit termina el hilo que la invoca.
  • 35. Hilos35 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Gestión de hilos básica (POSIX), ejemplo: Programa que crea un hilo donde muestra el mensaje “Hola Mundo” Para compilar el programa : • $ cc -D_REENTRANT thread2.c -o thread2 -lpthread
  • 36. Hilos36 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. int main() { pthread_create(a_thread,funcion_hilo); pthread_join(a_thread); } funcion_hilo() { … } Crea un hilo nuevo Espera a que termine el hilo creado Hilo principal Hilo creado con la llamada pthread_create
  • 37. Hilos37 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Gestión de hilos básica (POSIX) Pthread_join() • Hilo que ejecuta pthread_join, espera a que termine otro hilo El hilo principal debe esperar a que terminen todos los hilos creados • Si el hilo principal no espera a que terminen los hilos creados, al terminar termina el proceso con todos los hilos.
  • 38. Hilos38 Copyright © 2006, Intel Corporation. All rights reserved. Sistemas Operativos Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States or other countries. *Other brands and names are the property of their respective owners. Hilos en memoria Código (compartido) Datos (compartidos) Int cont=0 (var. Global) Stack (de cada hilo) Int i (var local) Stack (de cada hilo) Int i (var local)

Editor's Notes

  1. #include <pthread.h> int pthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); pthread_create crea un hilo y lo coloca en la cola de hilos. tid apunta al ID del hilo que se crea. Los atributos del hilo se encapsulan en el objeto atributo al que apunta attr si este es null, el nuevo hilo tendrá los atributos por omisión. start_routine, es el nombre de una rutina a la que el hilo invoca. El parámetro que se le especifica a start_routine es arg. #include <pthread.h> void pthread_exit(void *value_ptr); La función pthread_exit termina el hilo que la invoca. El valor del parámetro value_ptr queda disponible para pthread_join.
  2. #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <pthread.h> void *thread_function(void *arg); char message[] = "Hola mundo"; int main() { int res; pthread_t a_thread; void *thread_result; /* Aquí se crea el hilo */ res = pthread_create(&a_thread, NULL, thread_function, (void *)message); if (res != 0) { perror("Thread creation failed"); exit(EXIT_FAILURE); } printf("Esperando que el hilo termine...\n"); res = pthread_join(a_thread, &thread_result); if (res != 0) { perror("La unión del hilo ha fallado"); exit(EXIT_FAILURE); } printf("Hilo unido, regresó %s\n", (char *)thread_result); printf("El mensaje es %s\n", message); exit(EXIT_SUCCESS); } void *thread_function(void *arg) { printf("la función del hilo está corriendo. El Argumento fué %s\n", (char *) arg); sleep(3); strcpy(message, "Adios!"); pthread_exit("Gracias por el tiempo del CPU"); }
  3. #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <pthread.h> // Definen funciones para manejo de hilos void *thread_function(void *arg); // Función donde inicia el hilo int cont=0; // Es la misma para ambos hilos // Global está en el segmento de datos int main() { // Definición de variables int res; pthread_t a_thread; // Identificador del hilo void *thread_result; int i; // Es local, por lo tanto está en el segmento de stack de cada hilo /* Aquí se crea el hilo */ res = pthread_create(&a_thread, NULL, thread_function,NULL); if (res != 0) { perror("Thread creation failed"); exit(EXIT_FAILURE); } // Hilo principal for(i=1;i<=10;i++) { printf("%d\n",i); cont++; printf("Hilo principal dice cont=%d\n",cont); sleep(1); } printf("Esperando que el hilo termine...\n"); // Esperar a que termine el hilo cuyo identificador es a_thread res = pthread_join(a_thread, &thread_result); if (res != 0) { perror("La unión del hilo ha fallado"); exit(EXIT_FAILURE); } printf("Hilo unido, regresó %s\n", (char *)thread_result); exit(EXIT_SUCCESS); } // Función donde inicia la ejecución el hilo secundario void *thread_function(void *arg) { int i; // Es local, por lo tanto está en el segmento de stack de cada hilo for(i=10;i>0;i--) { printf("%d\n",i); printf("Hilo secundario dice cont=%d\n",cont); sleep(1); } pthread_exit("Gracias por el tiempo del CPU"); }