Concurrency and Processes of Pthreads

Ähnliche Dokumente
PThreads. Pthreads. Jeder Hersteller hatte eine eigene Implementierung von Threads oder light weight processes

4 Threads. FH Regensburg BT/SS04 Betriebssysteme Wirtschaftsinformatik. 4.1 Allgemein

KURZANLEITUNG. Firmware-Upgrade: Wie geht das eigentlich?

Exercise (Part XI) Anastasia Mochalova, Lehrstuhl für ABWL und Wirtschaftsinformatik, Kath. Universität Eichstätt-Ingolstadt 1

DIE NEUORGANISATION IM BEREICH DES SGB II AUSWIRKUNGEN AUF DIE ZUSAMMENARBEIT VON BUND LNDERN UND KOMMUNEN

Exercise (Part II) Anastasia Mochalova, Lehrstuhl für ABWL und Wirtschaftsinformatik, Kath. Universität Eichstätt-Ingolstadt 1

HIR Method & Tools for Fit Gap analysis

Hazards and measures against hazards by implementation of safe pneumatic circuits

SELF-STUDY DIARY (or Lerntagebuch) GER102

Linux Prinzipien und Programmierung

Mitglied der Leibniz-Gemeinschaft

Einsatz einer Dokumentenverwaltungslösung zur Optimierung der unternehmensübergreifenden Kommunikation

Echtzeitbetriebssysteme (am Beispiel QNX) Dr. Stefan Enderle HS Esslingen

Prediction Market, 28th July 2012 Information and Instructions. Prognosemärkte Lehrstuhl für Betriebswirtschaftslehre insbes.

TomTom WEBFLEET Tachograph

Algorithms for graph visualization

Patentrelevante Aspekte der GPLv2/LGPLv2

p^db=`oj===pìééçêíáåñçêã~íáçå=

Geometrie und Bedeutung: Kap 5

(Prüfungs-)Aufgaben zum Thema Scheduling

USB Treiber updaten unter Windows 7/Vista

1. General information Login Home Current applications... 3

Context-adaptation based on Ontologies and Spreading Activation

Aber genau deshalb möchte ich Ihre Aufmehrsamkeit darauf lenken und Sie dazu animieren, der Eventualität durch geeignete Gegenmaßnahmen zu begegnen.

The process runs automatically and the user is guided through it. Data acquisition and the evaluation are done automatically.

Dynamische Programmiersprachen. David Schneider STUPS

August Macke Abschied, 1914 Museum Ludwig, Köln

Programmierung eines GIMP-Plugin

Corporate Digital Learning, How to Get It Right. Learning Café

ISO Reference Model

Hör auf zu ziehen! Erziehungsleine Training Leash

U6-1 Organisatories. U6-2 Motivation von Threads. U6-3 Vergleich von Thread-Konzepten. Organisatorisches

Besprechung Aufgabe 5 (crawl) POSIX-Threads. Problem: UNIX-Prozesskonzept ist für viele heutige Anwendungen unzureichend

Darstellung und Anwendung der Assessmentergebnisse

Release Notes BRICKware Copyright 23. March 2010 Funkwerk Enterprise Communications GmbH Version 1.0

Cameraserver mini. commissioning. Ihre Vision ist unsere Aufgabe

Titelbild1 ANSYS. Customer Portal LogIn

Thema: Sonnenuhren (7.Jahrgangsstufe)

ALL1681 Wireless g Powerline Router Quick Installation Guide

Exercise (Part I) Anastasia Mochalova, Lehrstuhl für ABWL und Wirtschaftsinformatik, Kath. Universität Eichstätt-Ingolstadt 1

p^db=`oj===pìééçêíáåñçêã~íáçå=

Franke & Bornberg award AachenMünchener private annuity insurance schemes top grades

CABLE TESTER. Manual DN-14003

HUMANGENETIK IN DER WELT VON HEUTE: 12 SALZBURGER VORLESUNGEN (GERMAN EDITION) BY FRIEDRICH VOGEL

Prediction Market, 12th June 3rd July 2012 Information and Instructions. Prognosemärkte Lehrstuhl für Betriebswirtschaftslehre insbes.

NVR Mobile Viewer for iphone/ipad/ipod Touch

USB-Stick (USB-Stick größer 4G. Es ist eine größere Partition notwendig als die eines 4GB Rohlings, der mit NTFS formatiert wurde)

Das ist gut für die Gesundheit

WAS IST DER KOMPARATIV: = The comparative

Directions. Trouble shooting

How to access licensed products from providers who are already operating productively in. General Information Shibboleth login...

11: Echtzeitbetriebssystem ucos-ii

Tuesday 10 May 2011 Afternoon Time: 30 minutes plus 5 minutes reading time

Inequality Utilitarian and Capabilities Perspectives (and what they may imply for public health)

Virtual PBX and SMS-Server

Getting started with MillPlus IT V530 Winshape

Listening Comprehension: Talking about language learning

DOWNLOAD. Englisch in Bewegung. Spiele für den Englischunterricht. Britta Buschmann. Downloadauszug aus dem Originaltitel:

The English Tenses Die englischen Zeitformen

Parameter-Updatesoftware PF-12 Plus

Notice: All mentioned inventors have to sign the Report of Invention (see page 3)!!!

Elektronische Identifikation und Vertrauensdienste für Europa

Lehrstuhl für Allgemeine BWL Strategisches und Internationales Management Prof. Dr. Mike Geppert Carl-Zeiß-Str Jena

Lehrstuhl für Allgemeine BWL Strategisches und Internationales Management Prof. Dr. Mike Geppert Carl-Zeiß-Str Jena

Der Wetterbericht für Deutschland. Read the weather reports and draw the correct weather symbols for each town.

6KRSSLQJDW&DPGHQ/RFN 1LYHDX$

Invitation - Benutzerhandbuch. User Manual. User Manual. I. Deutsch Produktübersicht Beschreibung... 2

EEX Kundeninformation

ONLINE LICENCE GENERATOR

There are 10 weeks this summer vacation the weeks beginning: June 23, June 30, July 7, July 14, July 21, Jul 28, Aug 4, Aug 11, Aug 18, Aug 25

ISO Reference Model

fork () Hans-Georg Eßer, Hochschule München Betriebssysteme I, SS Prozesse (2/2) Folie 4

Harry gefangen in der Zeit Begleitmaterialien

J RG IMMENDORFF STANDORT F R KRITIK MALEREI UND INSPIRATION ERSCHEINT ZUR AUSSTELLUNG IM MUSEUM LU

NEWSLETTER. FileDirector Version 2.5 Novelties. Filing system designer. Filing system in WinClient

Flirt English Dialogue Transcript Episode Eight : On The Team

After sales product list After Sales Geräteliste

Copyright by Hildegard Heilmann IAG Diese Unterlagen stelle ich den SchülerInnen des V. Bachilleratos des IAG zur Verfügung.

Supplier Status Report (SSR)

GRIPS - GIS basiertes Risikoanalyse-, Informations- und Planungssystem

Umrüstung von SMA Wechselrichtern nach SysStabV Bernd Lamskemper

Objects First With Java A Practical Introduction Using BlueJ. Mehr über Vererbung. Exploring polymorphism 1.0

-Which word (lines 47-52) does tell us that Renia s host brother is a pleasant person?

Accounting course program for master students. Institute of Accounting and Auditing

Programmentwicklung ohne BlueJ

ReadMe zur Installation der BRICKware for Windows, Version ReadMe on Installing BRICKware for Windows, Version 6.1.2

STRATEGISCHES BETEILIGUNGSCONTROLLING BEI KOMMUNALEN UNTERNEHMEN DER FFENTLICHE ZWECK ALS RICHTSCHNUR FR EIN ZIELGERICHTETE

Cambridge International Examinations Cambridge International General Certificate of Secondary Education

Mash-Up Personal Learning Environments. Dr. Hendrik Drachsler

Technical Support Information No. 123 Revision 2 June 2008

EXPERT SURVEY OF THE NEWS MEDIA

Instruktionen Mozilla Thunderbird Seite 1

ABLAUF USI BÜRO INSKRIPTION

Advanced Availability Transfer Transfer absences from HR to PPM

Unterrichtsmaterialien in digitaler und in gedruckter Form. Auszug aus: Vertretungsstunde Englisch 6. Klasse: Grammatik

Die Kunst des Programmierens...

Restschmutzanalyse Residual Dirt Analysis

USBASIC SAFETY IN NUMBERS

eurex rundschreiben 094/10

Ways and methods to secure customer satisfaction at the example of a building subcontractor

Transkript:

Concurrency and Processes of Pthreads

Pthreads Pthreads is a POSIX standard for describing a thread model, it specifies the API and the semantics of the calls. POSIX: Portable Operating System Interface of UNIX Model popular nowadays practically all major thread libraries on Unix systems are Pthreads-compatible Solaris, FreeBSD, Linux Pthreads-win32

Preliminaries Include pthread.h in the main file Compile program with lpthread gcc -pthread -o test test.c may not report compilation errors otherwise but calls will fail Good idea to check return values on common functions

Types: pthread_t type of a thread Some calls: Thread basic API int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void * (*start_routine)(void *), void *arg); int pthread_join(pthread_t thread, void **status); int pthread_detach(); void pthread_exit(); No explicit parent/child model, except main thread holds process info Call pthread_exit in main, don t just fall through; Most likely you wouldn t need pthread_join status = exit value returned by joinable thread Detached threads are those which cannot be joined (can also set this at creation)

Attributes Type: pthread_attr_t (see pthread_create) Attributes define the state of the new thread Attributes: system scope, joinable, stack size, inheritance you can use default behaviors with NULL in pthread_create() int pthread_attr_init(pthread_attr_t *attr); int pthread_attr_destroy(pthread_attr_t *attr); pthread_attr_{set/get}{attribute} Example: pthread_attr_t attr; pthread_attr_init(&attr); // Needed!!! pthread_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); pthread_create(null, &attr, foo, NULL);

Pthread Mutexes Type: pthread_mutex_t int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr); int pthread_mutex_destroy(pthread_mutex_t *mutex); int pthread_mutex_lock(pthread_mutex_t *mutex); int pthread_mutex_unlock(pthread_mutex_t *mutex); int pthread_mutex_trylock(pthread_mutex_t *mutex); Attributes: for shared mutexes/condition vars among processes, for priority inheritance, etc. use defaults Important: Mutex scope must be visible to all threads!

Pthread semaphore int sem_init(sem_t *sem, int pshared, unsigned int value); int sem_wait(sem_t *sem); int sem_post(sem_t *sem);

The Dining Philosophers Problem Philosophers think take forks (one at a time) eat put forks (one at a time) Eating requires 2 forks Pick one fork at a time How to prevent deadlock? What about starvation? What about concurrency? Slide taken from a presentation by Gadi Taubenfeld, IDC 9

Dining philosophers: definition Each process needs two resources Every pair of processes compete for a specific resource A process may proceed only if it is assigned both resources Every process that is waiting for a resource should sleep (be blocked) Every process that releases its two resources must wake-up the two competing processes for these resources, if they are interested 10

An incorrect naïve solution ( means waiting for this fork ) 12

The LR Solution If the philosopher acquires one fork and the other fork is not immediately available, she holds the acquired fork until the other fork is free. R Two types of philosophers: L -- The philosopher first obtains its left fork and then its right fork. R -- The philosopher first obtains its right fork and then its left fork. L R L R The LR solution: the philosophers are assigned acquisition strategies as follows: philosopher i is R-type if i is even, L-type if i is odd. L 13

Assumption: the fork is fair. L R 6 0 R 3 2 L 4 1 L R ( means first fork taken ) 14

Thank you! I6LehreW16