A Gentler Introduction to Unix

Total Page:16

File Type:pdf, Size:1020Kb

A Gentler Introduction to Unix A Gentler Introduction to Unix Zhizhang Shen ∗ Dept. of Computer Science and Technology Plymouth State University April 21, 2020 Abstract Since this course is to run C/C++ in a Unix like environment, we start with a brief introduction to Unix, based on[1], to learn some of the basic Unix commands, the directory structure of the Unix system, and how to compile and run a C program consisting of either one file, or multiple files. In the rest of this course, we will then proceed to learn now to write programs in C to solve various problems, and then go through the same process as mentioned above to compile, and run, such programs. Later on, we will also look at a variety of Unix system calls, and shell scripts consisting of such calls, and see a comprehensive example as how C is used to write programs that make use of system information as kept by Unix. Contents 1 An introduction 3 1.1 Howtologintothesystem? .. .. .. .. .. ... .. .. .. .. ... .. 3 1.2 Simple Unix commands.............................. 3 2 Unix file system 6 2.1 Whatisinaname?................................ 8 2.2 Workwithfiles .................................. 10 2.3 Workwithdirectories. .. ... .. .. .. .. ... .. .. .. .. ... 14 2.4 Backgroundprocessing . 17 2.5 Miscellaneouscommands . 18 ∗Address correspondence to Dr. Zhizhang Shen, Dept. of Computer Science and Technology, Plymouth State University, Plymouth, NH 03264, USA. Email address: [email protected]. 1 3 A Unix shell 19 3.1 How does a shell work?.............................. 19 3.2 Optionsandargumentsofcommands . 20 3.3 Redirection .................................... 20 3.4 Groupcommands................................. 21 3.5 Pipesandtees................................... 21 3.6 Quotingspecialcharacters . 22 4 The editors 23 5 C programming in Unix 23 5.1 Firstthingfirst .................................. 24 5.2 Areyouboredwithit? .............................. 24 5.3 Speakmathematically .. ... .. .. .. .. ... .. .. .. .. ... .. 25 5.4 Cutitintopieces ................................. 26 6 A debugger 28 6.1 Setbreakpoints.................................. 30 6.2 Howtoproceedfromabreakpoint?. 31 6.3 Checkoutthevalues ............................... 32 6.4 Afinalexample.................................. 33 7 shell scripts 36 7.1 Positionalvariables .. .. ... .. .. .. .. ... .. .. .. .. ... 38 7.2 User-definedvariables. 41 8 Unix system interface 42 8.1 Lookatonecallindetails ... .. .. .. .. ... .. .. .. .. ... 42 8.1.1 Anexample ................................ 42 8.1.2 Anotherexample ............................. 44 8.1.3 Scriptsagain?............................... 45 8.2 Anexample:Listingdirectories . ..... 47 8.2.1 Givenastandardinterface... 48 8.2.2 ... and animplementationofthe interface . ..... 51 8.2.3 Alittlesummary ............................. 53 2 1 An introduction Unix is a popular, and powerful operating system 1, which supports multitasking and time- sharing (Think about how Turing is operating, where multiple users can use it “at the same time”.). It consists of a kernel, a file system, a shell, and various utilities. As the core of the system, the kernel controls everything inside the computer, and manages all kinds of resources, in particular, it implements various queues to support the multitasking ability, which we will further explore in CS 4310 Operating Systems. With the support of the file system, Unix organizes all kinds of data into a bunch of files, categorized into directories (Referred to as folders in Windows platform). The Unix shell interprets user commands and passes their requests to the kernel so that they can be further carried out. A utility is just a useful piece of software that makes the system more user friendly. For example, we can print out a calendar, list all the files out in various forms, find a word in a file, etc.. There are various versions of Unix, such as System V Unix, BSD Unix, and Unix-like systems, such as Linux. Turing is a Linux based system. As mentioned earlier, even Apple iOS is built on top of Unix. Since Unix is a multiuser system, we need a user account/password to get into the system, which is just the usual myPlymouth account credential. 1.1 How to log into the system? We can get into Turing via puTTY, an SSH and telnet client, with the above credential. The puTTY program can be found in all the programming labs in Memorial, and can also be obtained via https://www.putty.org/. If you use a MAC, try https://www.ssh.com/ssh/putty/mac/. Once you start puTTY, you should enter turing.plymouth.edu into the “Host Name” box 2, then click “Open”, as shown in Figure 1. You will then be prompted for your credential. If everything works out, it should look like Figure 2. You are now ready to play with it. , 1.2 Simple Unix commands Once getting into the system, we can immediately try out a few simple things. • Change your password. % passwd Changing password for user zshen. Current passworE: 1234567 1Both Apple iOS and Adnroid are based on Unix. 2You can use turing later on. 3 Figure 1: What does PuTTy look like? Figure 2: How to log into turing? New passworE: 7654321 Re-enter passworE: 7654321 passwE: all authentication tokens updated successfully. % Here, by ‘%’, we mean the command line prompt, or simply prompt. It is often associated with a user path, which we will explain further later on. For example, in my case, the actual prompt looks like the following (Cf. Figure 2): /home/zshen > Question: What is the path in your case? • What is the date today? 4 % date Tue Jan 7 08:06:31 EST 2020 • Who just logged on? % who am i zshen pts/0 2020-01-07 08:06 (vpnuser-1-20.plymouth.edu) • What is the command that you want to use? Here “man” certainly refers to “manual”. % man date DATE(1) UserCommands DATE(1) NAME date - print or set the system date and time ... • I am done. % logout Labwork 1.2: Unix commands are case sensitive. Try out the following commands with turing to see what happens: WHO, CAL 2018, DATE, Who Am I, e.g., % WHO You might also want to use the manual command 3 man to check if they are validate Unix commands, e.g., % man WHO Collect what you have done with the above in a ‘.txt’ file, using, e.g., Notepad++, and send it in as part of your report for this lab 4. (Check out the course page for the whole assignment for Lab 1.) 3Notice that you can exit the manual mode by entering ‘q’, standing for “quit”?. 4An effective and efficient way to send in a lab report for this course is to copy the stuff that you have done in turing, and paste them into a .txt file. Make sure that you will clearly label your solutions to the problems. For example, collect all the stuff you just did for Labwork1.2 after a label “Labwork1.2”. 5 2 Unix file system There is nothing special in terms of the file system, compared with what we have been dealing with every day with the Windows system, except perhaps a folder in Windows is referred to as a directory in Unix. An ordinary file can be either a text file or a binary file. A text file is usually represented as ASCII codes; and a binary file, on the other hand, is composed as a sequence of binary bits, intended for a computer to use. A special file contains information necessary to work with a certain device. There are lots of files kept in a computer. To facilitate a mundane task of looking for a file, a bunch of related files are organized into a directory, and a bunch of related directories are organized into a parent directory, ..., until everything is collected under a root directory. From an operating system’s perspective, a directory is also regarded as a file. Thus, the whole thing is organized as a tree, which you should know very well after taking CS2381 Data Structure and Intermediate Programming. Below shows an example of such a file system, based on a tree. Figure 3: An example of a Unix tree To dig a bit deeply, the very reason to use a tree structure to organize all these directories and files is that, as you should have learned in MA2200 Finite Mathematics, MA2250 Mathematics for Computer Scientists, or MA3200 Discrete mathematics, that, in such a structure, the path between any two nodes, especially that between the root directory and any other directory and/or file, is unique. This simple fact allows us to use the same name to uniquely identify different entities in such a structure, which will be made clear later when we discuss the naming of such entities as directories and files. Another fact is that it is relatively fast for use to look for a specific file in such a tree structure, which will be made clear when you take CS3221 Algorithm Analysis. 6 More specifically, at the top level, a Unix file tree contains the following directories: bin, containing the software for the shell and most of other commands; dev, containing all the special files, especially drivers, associated with various devices; etc, containing various administrative files, such as the list of the authorized users; home, containing the home directories of various users; tmp, containing you-know-what; usr, containing something useful; and var, containing something that varies, e.g., users’ mailboxes. When just logging into the system, you are in your working directory. For example, when I log into the system, I am in my working directory /home/zshen, as shown in Figure 2. You can always find out your current working directory by using the “print working directory” command pwd. % pwd /home/zshen % If you want to have a look at the tree structure rooted at the current working directory, you can use the tree command. For example, a sub-tree rooted at the working directory of counting is shown in Figure 4, where ls lists all the stuff in a working directory. Figure 4: Usage of the tree command Once you know where you are, you can change to any directory you want to work with, by using the “directory change” command, cd.
Recommended publications
  • UNIX Commands
    UNIX commands ls list the contents of a directory ls -l list the content of a directory with more details mkdir <directory> create the directory <directory> cd <directory> change to the directory <directory> cd .. move back one directory cp <file1> <file2> copy the file <file1> into <file2> mv <file1> <file2> move the file <file1> to <file2> rm <file> remove the file <file> rmdir <directory> delete the directory <directory> man <command> display the manual page for <command> module load netcdf load the netcdf commands to use module load ferret load ferret module load name load the module “name” to use its commands vi <file> read the content of the file <file> vimdiff <file1> <file2> show the differences between files <file1> and <file2> pwd show current directory tar –czvf file.tar.gz file compress one or multiple files into file.tar.gz tar –xzvf file.tar.gz extract the compressed file file.tar.gz ./name execute the executable called name qsub scriptname submits a script to the queuing system qdel # cancel the submitted job number # from the queue qstat show queued jobs qstat –u zName show only your queued jobs Inside vi ESC, then :q! Quit without saving ESC, then :wq Quit with saving ESC, then i Get in insert mode to edit text ESC, then /word Search content for word ESC, then :% Go to end of document ESC, then :0 Go to beginning of document ESC, then :set nu Add line numbers ESC, then :# Go to line number # N.B.: If inside vimdiff, you have 2 files opened, so you need to quit vi twice.
    [Show full text]
  • LATEX for Beginners
    LATEX for Beginners Workbook Edition 5, March 2014 Document Reference: 3722-2014 Preface This is an absolute beginners guide to writing documents in LATEX using TeXworks. It assumes no prior knowledge of LATEX, or any other computing language. This workbook is designed to be used at the `LATEX for Beginners' student iSkills seminar, and also for self-paced study. Its aim is to introduce an absolute beginner to LATEX and teach the basic commands, so that they can create a simple document and find out whether LATEX will be useful to them. If you require this document in an alternative format, such as large print, please email [email protected]. Copyright c IS 2014 Permission is granted to any individual or institution to use, copy or redis- tribute this document whole or in part, so long as it is not sold for profit and provided that the above copyright notice and this permission notice appear in all copies. Where any part of this document is included in another document, due ac- knowledgement is required. i ii Contents 1 Introduction 1 1.1 What is LATEX?..........................1 1.2 Before You Start . .2 2 Document Structure 3 2.1 Essentials . .3 2.2 Troubleshooting . .5 2.3 Creating a Title . .5 2.4 Sections . .6 2.5 Labelling . .7 2.6 Table of Contents . .8 3 Typesetting Text 11 3.1 Font Effects . 11 3.2 Coloured Text . 11 3.3 Font Sizes . 12 3.4 Lists . 13 3.5 Comments & Spacing . 14 3.6 Special Characters . 15 4 Tables 17 4.1 Practical .
    [Show full text]
  • PS TEXT EDIT Reference Manual Is Designed to Give You a Complete Is About Overview of TEDIT
    Information Management Technology Library PS TEXT EDIT™ Reference Manual Abstract This manual describes PS TEXT EDIT, a multi-screen block mode text editor. It provides a complete overview of the product and instructions for using each command. Part Number 058059 Tandem Computers Incorporated Document History Edition Part Number Product Version OS Version Date First Edition 82550 A00 TEDIT B20 GUARDIAN 90 B20 October 1985 (Preliminary) Second Edition 82550 B00 TEDIT B30 GUARDIAN 90 B30 April 1986 Update 1 82242 TEDIT C00 GUARDIAN 90 C00 November 1987 Third Edition 058059 TEDIT C00 GUARDIAN 90 C00 July 1991 Note The second edition of this manual was reformatted in July 1991; no changes were made to the manual’s content at that time. New editions incorporate any updates issued since the previous edition. Copyright All rights reserved. No part of this document may be reproduced in any form, including photocopying or translation to another language, without the prior written consent of Tandem Computers Incorporated. Copyright 1991 Tandem Computers Incorporated. Contents What This Book Is About xvii Who Should Use This Book xvii How to Use This Book xvii Where to Go for More Information xix What’s New in This Update xx Section 1 Introduction to TEDIT What Is PS TEXT EDIT? 1-1 TEDIT Features 1-1 TEDIT Commands 1-2 Using TEDIT Commands 1-3 Terminals and TEDIT 1-3 Starting TEDIT 1-4 Section 2 TEDIT Topics Overview 2-1 Understanding Syntax 2-2 Note About the Examples in This Book 2-3 BALANCED-EXPRESSION 2-5 CHARACTER 2-9 058059 Tandem Computers
    [Show full text]
  • RECEIPTS and CONTRACTS Bureau of Driver Training Programs Commissioner Regulations Part 76.8, Records and Contracts — Highlights Regarding
    RECEIPTS AND CONTRACTS Bureau of Driver Training Programs Commissioner Regulations Part 76.8, Records and Contracts — Highlights Regarding RECEIPT [Section 76.8 (a)(3) and (d)] A receipt is to be issued each time money is paid. Every receipt must show: u Name and address of the school u Amount paid u Duration of each lesson u Receipt number u Service rendered u Signature of an authorized representative of u Name of student u Contract number, if any the school u Date of payment The name and address of the school, and the receipt number, must be preprinted. Receipt numbers must be in sequence. The original receipt is given to the student; the duplicate is retained by the school in numeric order. Each contract or, if no contract is used, each receipt issued to a student, must include the following statement concerning refunds: (1) Except for contracts executed by schools licensed by the New York State Education Department and subject to the refund provisions of regulations promulgated by that Department, prepayment for lessons and other services shall be subject to refund as follows: if the student, having given prior notice of at least 24 hours, withdraws from or discontinues a prepaid course of instruction or series of lessons before completion thereof, or from any other service for which prepayment has been made, or if the school is unable or unwilling to complete such prepaid course of instruction, or series of lessons, or to provide such other prepaid service, all payments made by the student to the school shall be refunded except: (i) an amount equal to the enrollment fee, if any, specified in the contract or expressly receipted for, not to exceed the sum of $10 or 10 percent of the total, whichever is greater, specified cost of such course of instruction or series of lessons; and (ii) the school’s per-lesson tuition charge for each lesson already taken by the student which charge shall be determined by dividing the total cost of such course of instruction or series of lessons by the number of lessons included therein.
    [Show full text]
  • Command $Line; Done
    http://xkcd.com/208/ >0 TGCAGGTATATCTATTAGCAGGTTTAATTTTGCCTGCACTTGGTTGGGTACATTATTTTAAGTGTATTTGACAAG >1 TGCAGGTTGTTGTTACTCAGGTCCAGTTCTCTGAGACTGGAGGACTGGGAGCTGAGAACTGAGGACAGAGCTTCA >2 TGCAGGGCCGGTCCAAGGCTGCATGAGGCCTGGGGCAGAATCTGACCTAGGGGCCCCTCTTGCTGCTAAAACCAT >3 TGCAGGATCTGCTGCACCATTAACCAGACAGAAATGGCAGTTTTATACAAGTTATTATTCTAATTCAATAGCTGA >4 TGCAGGGGTCAAATACAGCTGTCAAAGCCAGACTTTGAGCACTGCTAGCTGGCTGCAACACCTGCACTTAACCTC cat seqs.fa PIPE grep ACGT TGCAGGTATATCTATTAGCAGGTTTAATTTTGCCTGCACTTGGTTGGGTACATTATTTTAAGTGTATTTGACAAG >1 TGCAGGTTGTTGTTACTCAGGTCCAGTTCTCTGAGACTGGAGGACTGGGAGCTGAGAACTGAGGACAGAGCTTCA >2 TGCAGGGCCGGTCCAAGGCTGCATGAGGCCTGGGGCAGAATCTGACCTAGGGGCCCCTCTTGCTGCTAAAACCAT >3 TGCAGGATCTGCTGCACCATTAACCAGACAGAAATGGCAGTTTTATACAAGTTATTATTCTAATTCAATAGCTGA >4 TGCAGGGGTCAAATACAGCTGTCAAAGCCAGACTTTGAGCACTGCTAGCTGGCTGCAACACCTGCACTTAACCTC cat seqs.fa Does PIPE “>0” grep ACGT contain “ACGT”? Yes? No? Output NULL >1 TGCAGGTTGTTGTTACTCAGGTCCAGTTCTCTGAGACTGGAGGACTGGGAGCTGAGAACTGAGGACAGAGCTTCA >2 TGCAGGGCCGGTCCAAGGCTGCATGAGGCCTGGGGCAGAATCTGACCTAGGGGCCCCTCTTGCTGCTAAAACCAT >3 TGCAGGATCTGCTGCACCATTAACCAGACAGAAATGGCAGTTTTATACAAGTTATTATTCTAATTCAATAGCTGA >4 TGCAGGGGTCAAATACAGCTGTCAAAGCCAGACTTTGAGCACTGCTAGCTGGCTGCAACACCTGCACTTAACCTC cat seqs.fa Does PIPE “TGCAGGTATATCTATTAGCAGGTTTAATTTTGCCTGCACTTG...G” grep ACGT contain “ACGT”? Yes? No? Output NULL TGCAGGTTGTTGTTACTCAGGTCCAGTTCTCTGAGACTGGAGGACTGGGAGCTGAGAACTGAGGACAGAGCTTCA >2 TGCAGGGCCGGTCCAAGGCTGCATGAGGCCTGGGGCAGAATCTGACCTAGGGGCCCCTCTTGCTGCTAAAACCAT >3 TGCAGGATCTGCTGCACCATTAACCAGACAGAAATGGCAGTTTTATACAAGTTATTATTCTAATTCAATAGCTGA
    [Show full text]
  • Presentation of the Results at HCVS on March 28
    Report on the 2021 edition Philipp Rümmer & Grigory Fedyukovich Outline ● Tracks and Benchmarks ● Teams and Solvers ● Results Tracks ● Linear Integer Arithmetic (LIA), linear clauses (LIA-Lin) ● LIA, nonlinear clauses (LIA-Nonlin) ● LIA and Arrays, linear clauses (LIA-Lin-Array) ● LIA and Arrays, nonlinear clauses (LIA-Nonlin-Array) ● Linear Real Arithmetic (LRA), transition systems (LRA-TS) ● LRA, transition systems, parallel (LRA-TS-Parallel) ● Algebraic Data Types (ADT), nonlinear (ADT-Nonlin) Tracks ● Linear Integer Arithmetic (LIA), linear clauses (LIA-Lin) ● LIA, nonlinear clauses (LIA-Nonlin) ● LIA and Arrays, linear clauses (LIA-Lin-Array) ● LIA and Arrays, nonlinear clauses (LIA-Nonlin-Array) ● Linear Real Arithmetic (LRA), transition systems (LRA-TS) ● LRA, transition systems, parallel (LRA-TS-Parallel) ● Algebraic Data Types (ADT), nonlinear (ADT-Nonlin) New in 2021 The Benchmarks New Benchmarks in 2021 ● Spacer ○ ADT+LIA benchmarks from Rust verification problems (post-processed afterwards) ○ LIA-Nonlin-Arrays benchmarks from SeaHorn ● RInGen ○ (Pure) ADT benchmarks from well-known TIP/Isaplanner suites ● FreqHorn ○ LIA-Lin benchmarks from the paper ● ADTCHC ○ Benchmarks from the paper ● NayHorn ○ LIA-NonLin benchmarks encoding syntax-guided synthesis problems ● SemGuS ○ LIA-NonLin-Arrays benchmarks encoding synthesis problems Benchmark Processing ● Benchmarks were selected among those available on https://github.com/chc-comp ● Processing for ADT-NonLin: ○ Purification e.g., to replace INT by NAT and SMT functions by recursive
    [Show full text]
  • The Intercal Programming Language Revised Reference Manual
    THE INTERCAL PROGRAMMING LANGUAGE REVISED REFERENCE MANUAL Donald R. Woods and James M. Lyon C-INTERCAL revisions: Louis Howell and Eric S. Raymond Copyright (C) 1973 by Donald R. Woods and James M. Lyon Copyright (C) 1996 by Eric S. Raymond Redistribution encouragedunder GPL (This version distributed with C-INTERCAL 0.15) -1- 1. INTRODUCTION The names you are about to ignore are true. However, the story has been changed significantly.Any resemblance of the programming language portrayed here to other programming languages, living or dead, is purely coincidental. 1.1 Origin and Purpose The INTERCAL programming language was designed the morning of May 26, 1972 by Donald R. Woods and James M. Lyon, at Princeton University.Exactly when in the morning will become apparent in the course of this manual. Eighteen years later (give ortakeafew months) Eric S. Raymond perpetrated a UNIX-hosted INTERCAL compiler as a weekend hack. The C-INTERCAL implementation has since been maintained and extended by an international community of technomasochists, including Louis Howell, Steve Swales, Michael Ernst, and Brian Raiter. (There was evidently an Atari implementation sometime between these two; notes on it got appended to the INTERCAL-72 manual. The culprits have sensibly declined to identify themselves.) INTERCAL was inspired by one ambition: to have a compiler language which has nothing at all in common with anyother major language. By ’major’ was meant anything with which the authors were at all familiar,e.g., FORTRAN, BASIC, COBOL, ALGOL, SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP,and PL/I. For the most part, INTERCAL has remained true to this goal, sharing only the basic elements such as variables, arrays, and the ability to do I/O, and eschewing all conventional operations other than the assignment statement (FORTRAN "=").
    [Show full text]
  • Your Contractual Questions Answered
    Your Contractual Questions Answered. Entrusty Group, a multi-displinary group of companies, of which, one of their specialisation is in project, commercial and contractual management, has been running a regular contractual questions and answers section for Master Builders members in the Master Builders Journal. In this instalment of this series, Entrusty Group will provide the answer to the frequently asked question - When must retention sum be released and paid ? Most if not all construction contracts used around the world usually have provisions for the retention of a certain amount of monies due to the Contractor by the Employer. This retention sum is normally retained by the Employer throughout the contract period and usually beyond the construction period up to the expiry of the defects liability period. Release of the retention sum is usually done in two portions. The first, called the one moiety, where half the retention sum is usually released with the issuance of the Certificate of Practical Completion and the remainder is usually released after expiry of the defects liability period and the issuance of Certificate of Making Good Defects by the Architect/Engineer/SO. Retention sums however, may be subjected to set-off by the Employer in accordance with the provisions in the contract. Standard Forms of Contract (Relevant Clauses) PAM Form of Building Contract Under PAM 98’s Clause 30.4 (69 – Cl.30(3)), it allows the Employer to retain a percentage of the total value of works, materials or goods as retention monies. The said percentage is stated in the Appendix as Percentage of Certified Value Retained.
    [Show full text]
  • Introduction to BASH: Part II
    Introduction to BASH: Part II By Michael Stobb University of California, Merced February 17th, 2017 Quick Review ● Linux is a very popular operating system for scientific computing ● The command line interface (CLI) is ubiquitous and efficient ● A “shell” is a program that interprets and executes a user's commands ○ BASH: Bourne Again SHell (by far the most popular) ○ CSH: C SHell ○ ZSH: Z SHell ● Does everyone have access to a shell? Quick Review: Basic Commands ● pwd ○ ‘print working directory’, or where are you currently ● cd ○ ‘change directory’ in the filesystem, or where you want to go ● ls ○ ‘list’ the contents of the directory, or look at what is inside ● mkdir ○ ‘make directory’, or make a new folder ● cp ○ ‘copy’ a file ● mv ○ ‘move’ a file ● rm ○ ‘remove’ a file (be careful, usually no undos!) ● echo ○ Return (like an echo) the input to the screen ● Autocomplete! Download Some Example Files 1) Make a new folder, perhaps ‘bash_examples’, then cd into it. Capital ‘o’ 2) Type the following command: wget "goo.gl/oBFKrL" -O tutorial.tar 3) Extract the tar file with: tar -xf tutorial.tar 4) Delete the old tar file with rm tutorial.tar 5) cd into the new director ‘tutorial’ Input/Output Redirection ● Typically we give input to a command as follows: ○ cat file.txt ● Make the input explicit by using “<” ○ cat < file.txt ● Change the output by using “>” ○ cat < file.txt > output.txt ● Use the output of one function as the input of another ○ cat < file.txt | less BASH Utilities ● BASH has some awesome utilities ○ External commands not
    [Show full text]
  • MPI Programming — Part 2 Objectives
    MPI Programming | Part 2 Objectives • Barrier synchronization • Broadcast, reduce, gather, scatter • Example: Dot product • Derived data types • Performance evaluation 1 Collective communications In addition to point-to-point communications, MPI includes routines for performing collective communications, i.e., communications involving all processes in a communicator, to allow larger groups of processors to communicate, e.g., one-to-many or many-to-one. These routines are built using point-to-point communication routines, so in principle you could build them yourself. However, there are several advantages of directly using the collective communication routines, including • The possibility of error is reduced. One collective routine call replaces many point-to-point calls. • The source code is more readable, thus simplifying code debugging and maintenance. • The collective routines are optimized. 2 Collective communications Collective communication routines transmit data among all processes in a communicator. It is important to note that collective communication calls do not use the tag mechanism of send/receive for associating calls. Rather, calls are associated by the order of the program execution. Thus, the programmer must ensure that all processes execute the same collective communication calls and execute them in the same order. The collective communication routines can be applied to all processes or a specified set of processes as defined in the communicator. For simplicity, we assume all processes participate in the collective communications, but it is always possible to define a collective communication between a subset of processes with a suitable communicator. 3 MPI Collective Communication Routines MPI provides the following collective communication routines: • Barrier sychronization across all processes.
    [Show full text]
  • IBM ILOG CPLEX Optimization Studio OPL Language Reference Manual
    IBM IBM ILOG CPLEX Optimization Studio OPL Language Reference Manual Version 12 Release 7 Copyright notice Describes general use restrictions and trademarks related to this document and the software described in this document. © Copyright IBM Corp. 1987, 2017 US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Trademarks IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml. Adobe, the Adobe logo, PostScript, and the PostScript logo are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States, and/or other countries. Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. UNIX is a registered trademark of The Open Group in the United States and other countries. Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both. Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates. Other company, product, or service names may be trademarks or service marks of others. © Copyright IBM Corporation 1987, 2017. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Figures ............... v Limitations on constraints ........ 59 Formal parameters ...........
    [Show full text]
  • Gnu Coreutils Core GNU Utilities for Version 6.9, 22 March 2007
    gnu Coreutils Core GNU utilities for version 6.9, 22 March 2007 David MacKenzie et al. This manual documents version 6.9 of the gnu core utilities, including the standard pro- grams for text and file manipulation. Copyright c 1994, 1995, 1996, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled \GNU Free Documentation License". Chapter 1: Introduction 1 1 Introduction This manual is a work in progress: many sections make no attempt to explain basic concepts in a way suitable for novices. Thus, if you are interested, please get involved in improving this manual. The entire gnu community will benefit. The gnu utilities documented here are mostly compatible with the POSIX standard. Please report bugs to [email protected]. Remember to include the version number, machine architecture, input files, and any other information needed to reproduce the bug: your input, what you expected, what you got, and why it is wrong. Diffs are welcome, but please include a description of the problem as well, since this is sometimes difficult to infer. See section \Bugs" in Using and Porting GNU CC. This manual was originally derived from the Unix man pages in the distributions, which were written by David MacKenzie and updated by Jim Meyering.
    [Show full text]