Coder Social home page Coder Social logo

guykabiri / gcd-calculator-in-c-using-processes Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 12 KB

An Exercise as a part of the `Operation Systems` course. Calculate the gcd of pairs of numbers using processes and pipes in C.

Makefile 2.15% C 97.85%
gcd-calculator pipes gcd lock processing process c

gcd-calculator-in-c-using-processes's Introduction

GCD Calculator in C using Processes

A small Unix / Linux assignment in the 'Operation Systems' course which calculates the GCD of pairs of numbers. There are 2 versions, one that using a process for each pair, and one that uses a constant number of processes and communicates with the main process using pipes.

V1

V1 reads pairs of numbers from STDIN and use the command line argument to pass the two numbers to the child process, then using the exit status of the child process to read calculated gcd.

Usage

Run ./v1_parent in the command line in v1 folder, or ./v1/v1_parent in the main folder.

Press ctrl + d to stop.

V2

V2 reads pairs of numbers from a file, the file name should be given in the command line as an argument. The two numbers and the calculated gcd is passed through pipes.

Usage

Run ./v2_parent file_name in the command line in v2 folder, or ./v2/v2_parent file_name in the main folder, where file_name is a file with pairs of numbers seperated with spaces or tabs, one pair in each row.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.