Introduction to Concurrency Concurrency: Execute two or more pieces of code “at the same time” Why? No choice: - Geographically distributed data - Interoperability of different machines - A piece of code must”serve” many other client processes - To achieve reliability By Choice: to achieve speedup sometimes makes programming easier (e.g. UNIX pipes)
Introduction to Concurrency. Concurrency: Execute two or more pieces of code “at the same time” Why? No choice: - Geographically distributed data - Interoperability of different machines - A piece of code must”serve” many other client processes - To achieve reliability - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Introduction to ConcurrencyConcurrency:Execute two or more pieces of code “at the same time”
Why?No choice:- Geographically distributed data- Interoperability of different machines- A piece of code must”serve” many other client processes- To achieve reliability
By Choice:to achieve speedupsometimes makes programming easier (e.g. UNIX pipes)
If the call to pipe() succeeded, a pipe will be created, pipes[0] will contain the number of its read file descriptor, and pipes[1] will contain the number of its write file descriptor.
Write() system callWrite() – used to write data to a file or other object identified
PARAMETERfildes is the file descriptor,buf is the base address of area of memory that data is copied from,nbyte is the amount of data to copy
RETURN VALUEThe return value is the actual amount of data written, if this differs from nbyte then something has gone wrong
Read() system callRead() – read data from a file or other object identified by a file descriptor
SYNOPSIS
#include <sys/types.h>
Size_t read(int fildes, void *buf, size_t nbyte);
ARGUMENTfildes is the file descriptor,buf is the base address of the memory area into which the data is read, nbyte is the maximum amount of data to read.
RETURN VALUEThe actual amount of data read from the file. The pointer is incremented by the amount of data read.