Sistemas Operativos Semáforos.

Slides:



Advertisements
Presentaciones similares
-go Verbs There is a small but very important group of verbs that we call the -go verbs. These verbs are: Conocer : to know (people) Hacer: to make/do.
Advertisements

Tener Lets look at the verb tener (to have). It features two verb changes that we will see very soon.
Lunes el diecinueve de marzo. The future tense is used in Spanish to talk about future events. It is used when ever we would use the phrase I will… in.
-go Verbs There is a small but very important group of verbs that we call the -go verbs. These verbs are: Hacer: to make/do Poner: to put Decir: to say.
-go Verbs There is a small but very important group of verbs that we call the -go verbs. These verbs are: Hacer: to make/do Poner: to put Salir: to leave.
Control en cascada.
Comunicación y sincronización de procesos
INFORMATICA I Funciones CLASE 13.
Comunicación entre procesos en Linux
Concurrencia en JAVA JAVA es un lenguaje que tiene soporte de concurrencia, mediante Threads. Un thread es un proceso “liviano” (lightweight process) que.
E-I Pedir ayuda = To ask for help -Yo pido ayuda en la clase -Tu pides ayuda en la casa -Juancho pide ayuda todos los dias -Nosotros pedimos ayuda -Ellos.
WALT: talking about dates and saying when your birthday is WILF: To be able to write & understand months and dates in Spanish to get to a Level 2 To be.
Programación orientada a objetos
Naming Covalent Compounds Day II. Do Now  Fill out the ‘Do Now’ section on your Do Now and Daily Evaluation Sheet  Rellene el 'Do Now' sección de su.
Stem-changing verbs.
Sincronización de Procesos Semáforos Emely Arráiz Ene-Mar 08.
Semáforos Cecilia Hernández
Future. Before learning to form the future it in English: I will speak. The future tense in English ALWAYS has the word “will” (or “shall”). It can be.
-go Verbs There is a small but very important group of verbs that we call the “-go” verbs. These verbs are: Hacer: to make/do Poner: to put Salir: to.
C. E. I. P. MONTEALBO Montalbán de Córdoba (Spain) El presente proyecto ha sido financiado con el apoyo de la Comisión Europea y dentro del Programa de.
Telling Time.
 El acceso concurrente a datos compartidos puede dar pie a inconsistencia de datos  Mantener la consistencia de los datos requiere mecanismos para asegurar.
Fact Family4, 5, 20 (provided by the teacher) Problem4 X 5= 20 Perimeter = 18 cm Area4 x 5= 20 sq cm 5 cm 4 cm Example: Teachers: Assign students.
The Present Subjunctive The Subjunctive l Up to now you have been using verbs in the indicative mood, which is used to talk about facts or actual events.
Vistas: La página 59 Los precios El número de teléfono La dirección de correo electrónico.
Hoy es el 1º de noviembre Please turn in your homework to the sub. Please complete this hand out entirely and turn in to the sub. Calentamiento: Complete.
LOS VERBOS IRREGULARES ‘YO’ – 5.2 Pregunta esencial: How do I talk about planning a party using irregular ‘yo’ verbs in the present tense?
First Grade – High Frequency Word Reading Competition Classroom Competition Created by: Malene Golding School Improvement Officer: Kimberly Fonteno.
Telling Time La hora. Telling Time To ask what time it is in Spanish, ask: ¿Qué hora es? To answer: Es la una… (12:31 – 1:30) or Son las (hour). (1:31.
SEMÁFOROS §Conceptos l Mecanismo para prevenir la colisión que se produce cuando dos o más procesos solicitan simultáneamente el uso de un recurso que.
Español 1 Hoy es lunes el 10 de marzo de La Campana Escribe dónde, a tu familía, le gusta ir en español. Ejemplo: A mi primo le gusta ir a la biblioteca.
First Grade – High Frequency Word Reading Competition Classroom Competition Created by: Malene Golding School Improvement Officer: Kimberly Fonteno.
¿Qué haces en la escuela? Question words, objects, yo-go’s.
Las Preguntas (the questions) Tengo una pregunta… Sí, Juan habla mucho con el profesor en clase. No, Juan no habla mucho en clase. s vo s vo Forming.
Progressive. The progressive consist of two parts: a helping verb and the present participle of a main verb, which ends in –ing in English: is talking.
Objetivo: How do we describe ourselves? Hagan Ahora: In your notebooks, conjugate ser into all six forms. When you receive your workbook, write your first.
-go Verbs There is a small but very important group of verbs that we call the “-go” verbs. These verbs are: Hacer: to make/do ( not on worksheet so add.
The Present Subjunctive P. 410 Realidades 2. The Subjunctive Up to now you have been using verbs in the indicative mood, which is used to talk about facts.
-go Verbs There is a small but very important group of verbs that we call the “-go” verbs. These verbs are: Conocer : to know (people) Hacer: to make/do.
Monday & Tuesday 26/8/13 & 27/8/13 Please remember to get your folder! You will need a textbook today, so please get one. First Five Get ready to go over.
1. Escribe la fecha y el objetivo. 2. Saca la tarea! 3. Translate the following sentences from Spanish to English. 1. Me gustan los deportes porque son.
Time Telling time is rather easy. You only need to know the numbers up to 59 to be able to tell the time.
Telling Time on the Hour If the hours are between 2 and 12, use “Son las …” Examples: 3:00 – Son las tres. 11:00 – Son las once. If the hour is within.
Spanish Sentence Structure How can we make better sentences?
The Future Tense -original PowerPoint created by Mrs. Shirley of North Intermediate High School in Broken Arrow, OK.
DELETE THIS SLIDE BEFORE HANDING IN See the rubric for more details Deadlines will not change, no excuses…all projects must be ed
Calentamiento Write the answers to the questions in SPANISH
Portafolios E E- Portfolios What is - Qué es e-portfolio? e-Portfolio: A portfolio is a collection of work developed across varied contexts over.
Articles in Spanish Reflect gender and number in nouns.
-go Verbs There is a small but very important group of verbs that we call the “-go” verbs. These verbs are: Conocer : to know (people) Hacer: to make/do.
Direct Objects & Direct Object Pronouns An English and Spanish Lesson.
[nombre del país] Capital: [nombre del capital] por [tu nombre] el 16 de mayo.
ALC 49 Responde a las preguntas Hoy es lunes el 30 de enero ¿Cómo estás? 2.¿Dónde estás? 3.¿Qué estás haciendo? 4.¿De dónde eres? 5.¿Cómo eres?
Indirect Object Pronouns Original PowerPoint was by Ms. Martin of Tri-Center Community Schools.
Un juego de adivinanzas: ¿Dónde está el tesoro? A1B1C1D1E1F1 A4B4C4D4E4F4 A2B2C2D2E2F2 A5B5C5D5E5F5 A3B3C3D3E3F3 A6B6C6D6E6F6 Inténtalo de nuevo Inténtalo.
Para empezar- El presente Read the following sentences and fill in each appropriate verb form 1.La clase siempre ____________para los exámenes. (estudiar)
Escribe las tres formas para presentarte (Write down three ways to introduce yourself) 1. _______________________________ 2.________________________________.
Antes de empezar – ¿Cómo se llaman estos quehaceres? (Necesito la tarea.)
LOS VERBOS REFLEXIVOS. WRITE: What is a reflexive verb? A reflexive verb describes when a person doing an action is also receiving the action.
Global Warming Project and Presentation. Save this PowerPoint to your S- User Then, answer the following questions about Global Warming. (Luego contesta.
Definite & indefinite articles The articles el, la, los & las are definite articles and mean “the” when translated into English. Use these when talking.
La Fecha: Hoy es martes, 30 de septiembre Objective: SWBAT use the verb tener in Spanish to talk about things that you and others have and have to do.
EspaÑol 1 Lesson 3 30 de Agosto de 2016
Progressive.
EL TIEMPO PRESENTE ESPAÑOL 2.
Antes de empezar contesta las preguntas sólo escribe las respuestas
Arrays Programming COMP102 Prog. Fundamentals I: Arrays / Slide 2 Arrays l An array is a collection of data elements that are of the same type (e.g.,
Welcome to PowerPoint gdskcgdskfcbskjc. Designer helps you get your point across PowerPoint Designer suggests professional designs for your presentation,
Las Preguntas (the questions) Tengo una pregunta… Sí, Juan habla mucho con el profesor en clase. No, Juan no habla mucho en clase. s vo s vo Forming.
Transcripción de la presentación:

Sistemas Operativos Semáforos

Se necesitan para Sincronizar Procesos Exclusión mutua Zonas críticas Abstracción de recursos Semáforo: una variable que permite o no el paso Sem = 0 disponible Sem >< 0 ocupado Una cola asociada

Una aproximación CIERRE(X) APERTURA(X) EXAM: X = 0; If X = Ocupado Go to EXAM; X := 1; Loop de uso procesador – Inseguro por interrupción

Modificaciones Test&Set (x) Wait (x) (duerme proceso en cola asociada) (FIFO) Signal (x) (depierta proceso de la cola asociada) (¿dónde lo pone?)

Nueva aproximación CIERRE(X) APERTURA(X) EXAM: T.S.(X) X = 0 If X = Ocupado then WAIT(X) SIGNAL(X) Go to EXAM ¿por qué volver EXAM?

Dijkstra (semáforos contadores) P (x) x = x - 1 si x < 0, wait (x) V(x) x = x + 1 si x £ 0, signal (x)

Modelo de Exclusión Init sem x = 1 V(x) P(x) V(x) ¿cómo incide en la administración de procesos?

Modelo Productor Consumidor

Modelo P/C un mensaje Init Espacio = 1 Mensaje = 0 EMISOR RECEPTOR P(Espacio) P(Mensaje) . . Coloca inf. Retira inf. V(Mensaje) V(Espacio)

Modelo P/C con más de un espacio (emisor) E Mensaje = 0 P(Espacio) Espacio = 3 VEC(i) = M i = 0 i = (i+1) módulo 3 V(Mensaje)

Modelo P/C con más de un espacio (consumidor) P(Mensaje) j = 0 X = VEC(j) j = (j+1) módulo 3 V(Espacio)

Problemas Siempre que hay cambio de información, por datos o por estructuras, es necesario excluir (serializar) Problemas de las exclusiones

Problemas Productor P(Exclu) P(Espacio) VEC(i) = M i = (i+1) módulo 3 V(Mensaje) V(Exclu)

Problemas Consumidor P(Exclu) P(Mensaje) X = VEC(j) j = (j+1) módulo 3 V(Espacio) V(Exclu)

Solución Productor P(Espacio) P(Exclu) VEC(i) = M i = (i+1) módulo 3 V(Exclu) V(Mensaje)

Solución Consumidor P(Mensaje) P(Exclu) X = VEC(j) j = (j+1) módulo 3 V(Exclu) V(Espacio)

Implementado con stack E (semáforo) = MAX = 3 (cuenta el máximo de mensajes producibles) S (semáforo) = 0 (cuenta el número de mensajes disponibles para consumo) X (semáforo de exclusión) = 1

Stack

Prod/Cons Implementación Stack con exclusión bien puesta Las rutinas serán : A (Productor) B (Consumidor) P(E) P(S) P(X) P(X) [1] P = genera apuntador [2] C = Primero P.Mensaje = Dato [5] Primero=C.Próximo [3] P. Próx = Primero Dato = C.Mensaje [4] Primero = P Libera C V(X) V(X) V(S) V(E)

Si suponemos sin exclusión

Estudio de casos 0) A Prod B y C Cons sec. ABCABC... 1) A prod B Cons sec. ABBABB... 2) idem sec. A (BC) o A (CB)... 3) idem sec. ABCACBABCACB...

Implementación

Implementación /* One semid data structure for each set of semaphores in the system. */ struct semid_ds { struct ipc_perm sem_perm; /* permissions .. see ipc.h */ time_t sem_otime; /* last semop time */ time_t sem_ctime; /* last change time */ struct sem *sem_base; /* ptr to first semaphore in array */ struct wait_queue *eventn; struct wait_queue *eventz; struct sem_undo *undo; /* undo requests on this array */ ushort sem_nsems; /* no. of semaphores in array */ };

Implementación sem_perm This is an instance of the ipc_perm structure, which is defined for us in linux/ipc.h. This holds the permission information for the semaphore set, including the access permissions, and information about the creator of the set (uid, etc). sem_otime Time of the last semop() operation (more on this in a moment) sem_ctime Time of the last change to this structure (mode change, etc) sem_base Pointer to the first semaphore in the array (see next structure) sem_undo Number of undo requests in this array (more on this in a moment) sem_nsems Number of semaphores in the semaphore set (the array)

Implementación IPC (crea semáforo) #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include <stdio.h> #define KEY (1492) void main() { int id; /* Number by which the semaphore is known within a program */ ... id = semget(KEY, 1, 0666 | IPC_CREAT); }

Implementación IPC (operación V) #include <sys/types.h> ... #define KEY (1492) void main() { int id; id = semget(KEY, 1, 0666); /* Which semaphore in the semaphore array : */ operations[0].sem_num = 0; /* Which operation? Add 1 to semaphore value : */ operations[0].sem_op = 1; /* Set the flag so we will wait : */ operations[0].sem_flg = 0;  /* So do the operation! */ retval = semop(id, operations, 1); (sobre retval se pregunta) }

Implementación IPC (operación P) #include <sys/types.h> ... #define KEY (1492) void main() { int id; id = semget(KEY, 1, 0666); /* Which semaphore in the semaphore array : */ operations[0].sem_num = 0; /* Which operation? Substract 1 to semaphore value : */ operations[0].sem_op = -1; /* Set the flag so we will wait : */ operations[0].sem_flg = 0;  /* So do the operation! */ retval = semop(id, operations, 1); (sobre retval se pregunta) }

Implementación POSIX P1003.1b Function Description sem_close Deallocates the specified named semaphore sem_destroy Destroys an unnamed semaphore sem_getvalue Gets the value of a specified semaphore sem_init Initializes an unnamed semaphore sem_open Opens/creates a named semaphore for use by a process sem_post Unlocks a locked semaphore sem_trywait Performs a semaphore lock on a semaphore only if it can lock the semaphore without waiting for another process to unlock it sem_unlink Removes a specified named semaphore sem_wait Performs a semaphore lock on a semaphore

Implementación POSIX The following example creates a semaphore named /tmp/mysem with a value of 3 #include <sys/types.h> #include <stdio.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <sys/mman.h> #include <semaphore.h> #include <sys/stat.h>

Implementación POSIX sem_t *mysemp; int oflag = O_CREAT; mode_t mode = 0644; const char semname[] = "/tmp/mysemp"unsigned int value = 3; int sts; … mysemp = sem_open(semname, oflag, mode, value); if (mysemp == (void *)-1) { perror(sem_open() " failed "); } To access a previously created semaphore, a process must call the sem_open function using the name of the semaphore.

Implementación POSIX Exclusión Mutua void *t1 void *t2 ... ... sem_wait(*sem) sem_wait(*sem) Zona Crítica Zona Crítica sem_post(*sem) sem_post(*sem) sem_init(*sem,0,1)