>

COSC330/530 - Parallel and Distributed Computing

Lecture 1 - Introduction

Dr. Mitchell Welch


Reading


Summary


Welcome to COSC330/530


Welcome to COSC330/530


House-Keeping


House-Keeping


House-Keeping


House-Keeping


center-aligned image


House-Keeping

Hi Mitchell,

Would it be possible for you to grant me an extension on assignment 2 till next Friday?

Kind regards,

John


House Keeping


Concurrency and Parallelism


Concurrency and Parallelism


Concurrency and Parallelism


Concurrency and Parallelism


Resources and Machines


Resources and Machines


Why Construct Concurrent Implementations?


center-aligned image

Source: https://github.com/karlrupp/microprocessor-trend-data


Why Construct Concurrent Implementations?


Why Construct Concurrent Implementations?


UNIX Environment Overview


UNIX Environment Overview


center-aligned image


UNIX Environment Overview


UNIX Environment Overview

ls -la /dev

UNIX Environment Overview


UNIX Environment Overview

#include <stddef.h>
#include <stdio.h>
#include <dirent.h>
#include <stdlib.h>

void
main(int argc, char *argv[])
{
    DIR                *dp;
    struct dirent    *dirp;
    if (argc != 2)
        perror("usage: ls directory_name");
    if ((dp = opendir(argv[1])) == NULL )
        perror("can't open file");
    while ((dirp = readdir(dp)) != NULL )
        printf("%s\n", dirp->d_name);
    closedir(dp);
    exit(0);
}


UNIX Environment Overview


UNIX Evironment Overview


UNIX Environment Overview

#include <stddef.h>
#include <stdio.h>
#include <dirent.h>
#include <stdlib.h>
#include <unistd.h>

#define    BUFFSIZE    4096
int
main(void)
{
    int        n;
    char    buf[BUFFSIZE];
    while ((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0)
        if (write(STDOUT_FILENO, buf, n) != n)
            perror("write error");
    if (n < 0)
        perror("read error");
    exit(0);
}

UNIX Environment Overview


UNIX Environment Overview

#include <stddef.h>
#include <stdio.h>
#include <dirent.h>
#include <stdlib.h>
#include <unistd.h>

int
main(void)
{
    int        c;
    while ((c = getc(stdin)) != EOF)
        if (putc(c, stdout) == EOF)
            perror("output error");
    if (ferror(stdin))
        perror("input error");
    exit(0);
}

UNIX Environment Overview

int open(const char *path, int oflags [,mode_t mode]);

UNIX Environment Overview

int close(int fildes);

UNIX Environment Overview

#include <unistd.h>
#include <fcntl.h>

int main(){
    int filedesc = open("testfile.txt", O_WRONLY | O_APPEND);
    if(filedesc < 0)
        return 1;
    if(write(filedesc,"Output to testfile.txt\n", 36) != 36){
        write(2,"Error writing to testfile.txt\n",30);
        return 1;
    }
    close(filedesc);
    return 0;
}   

UNIX Environment Overview

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(void){
    printf("My Process ID \%ld\n", (long)getpid());
    exit(0);
}

UNIX Environment Overview

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h> 
#include <sys/wait.h>

int main(void){
   pid_t pid = fork();
   if (pid == -1){
      exit(EXIT_FAILURE);
   }
   else if (pid == 0) {
      printf("Hello from the child process!\n");
      _exit(EXIT_SUCCESS);  
   }
   else {
      int status;
      (void)waitpid(pid, &status, 0);
   }
   return EXIT_SUCCESS;
}   

UNIX Environment Overview

void perror(const char* msg);


UNIX Environment Overview


Summary


Questions?


Next Lecture


Reading