CSCI 5103
Spring 2018

Class Information
Lecture Schedule and Notes
Assignments and Exams
Class Forum (Moodle)
Assignment Submission (Moodle)
Grades (Moodle)
Examples
Useful Resources
CSCI 4061
Operating Systems

CSCI 5103   -   Spring 2018

Examples



File I/O Examples
  • Echo It reads lines from stdin and writes to stdout.
  • File copy It creates a copy of an existing file.
  • File append It appends a file at the end of another file.
  • seekout - an example of lseek An example of lseek, creates null bytes by seeeking beyond the end of the file.
  • myls0.c myls1.c myls2.c myls3.c myls4.c myls5.c mylsFinal.c Example of opendir and readdir to list a directory's content. stat call, ctime, getpwuid, getgrgid
  • statdemo.c Getting sum of all files in a directory using stat.
  • lstatdemo.c Prints file type (dir, reg, lnk) for each file in a directory
  • dupdemo.c Using dup to redirect output from a file to standard output.
  • makdir.c Make a new directory
  • rmvdir.c Remove a directory
  • rmvfile.c Remove a file
  • changedir.c  Change the current working directory of the process executing this code
  • pwdir.c   getcwd.c Print current working directory
  • myfind.c  A simple version of "find" program to find in a specified directory all files whose names contain a given string. NOTE: No wildcards accepted.
  • If you execute as "myfind   dirname  hel"
  • It will find files with names such as hello.c, help.txt, shell.txt,  if present in the directory tree specified by "dirname". Their names contain string "hel".
  • linkinfo.c  This program reads all entries in a given directory, and for each  symbolic link in the directory, it prints the link information, i.e. the path information contained in the link.  This program makes use of the system call function readlink().
  • makelink.c  This program creates a new symbolic link (path name) for an existing file. It uses system call function symlink(). This program is similar to "ln -s" for creating a symbolic link.
  • fmtout.c Examples for formatted output
  • fmtinput.c Examples for formatted input. citylist Examples of input for the formatted input example program.
  • timeinfo.c  This example shows how to use strftime(0 function to generate current date time in a desired format such as MONTH-DD-YYYY-HH-MM-SS, e.g.  Feb-13-2013-16-59-08
Process Management
  • Description of various examples in this section
  • printpid.c Print process id, parent process id, user id.
  • process-chain.c Example of repeated fork calls to create a chain of parent-child. Example 2.5 from the book.
  • process-fan.c Example 2.6 from the book.
  • process-tree.c Example 2.7 from the book.
  • Example 1 Example of fork-exec using execl.
  • Example 2 Example of fork-exec using execv.
  • Example 3 Example of fork-exec in which the child executes a shell command
  • Example 4 Example of fork-exec -  parent waits for child finish and return its PID as status
  • Example 5 Parent opens the file with name "input", 
  •                     creates a child, across the fork child and parent will share the file descriptor
  •                     both child and parent read from the same descriptor and the output  gets interleaved by the outputs of the two
  • Example 6  Parent creates the child  and uses the WNOHANG option of waitpid. Parent is not blocked in wait.
  • Pipeline Example of creating a pipe between two processes.
  • Exit status of a child process Example of how a process obtains exit status of its child.
 Examples of POSIX Thread Programming
  • POSIX Thread Programming Examples
Concurrent Programming
  • Serilized writing to stderr by concurrent children This example illustrates the output produced when child processes in a process chain write to stderr in a serial order.
  • Interleaved writing to stderr by concurrent children when the writes are not synchronized. This example illustrates the output produced when child processes in a process chain write concurrently to stderr in a unsychronized manner.
  • Examples of concurrent programming using POSIX seamphores, shared memory, System V semaphores
Examples of SYSTEM V Semaphores
  • System V sempahore Examples
Signal Management
  • Example programs for signal handling
  • More example programs for signal handling
String Manipulation
  • pathparse.c Parsing a path into filename & base
  • str_demo.c Another string manipulation demo
  • strtok_ex.c Parsing strings into tokens using strtok
  • get_strings.c Using fgets to retrieve strings from a file
Dynamic Memory
  • Shared Memory
  • dynamic1.c A demo of malloc and free
  • dynamic2.c A demo of calloc and realloc
TCP/IP Example Programs
  • TCP, UDP, sockets and select() Examples from recitation
Linux Device Drivers

      Compressed tar file examples from ORielly Book --   linux-module-examples.tgz

      See the kernel module examples program from the ORielly Book