Git Product home page Git Product logo

cscios's Introduction

CSCI 380: Operating Systems

Coins

Modify Coins.c to support half dollars, coins worth 50 cents.

  • Add a new member to the struct
  • Output "penny" if only one is needed. Use a const char * variable and conditional to do this.
  • Test various inputs to ensure your logic is correct.

Queue

Your task is to modify the code in queue.h and queue.c to fully implement the following functions.

  • q_new: Create a new, empty queue.
  • q_free: Free all storage used by a queue.
  • q_insert_head: Attempt to insert a new element at the head of the queue (LIFO discipline).
  • q_insert_tail: Attempt to insert a new element at the tail of the queue (FIFO discipline).
  • q_remove_head: Attempt to remove the element at the head of the queue.
  • q_size: Compute the number of elements in the queue.
  • q_reverse: Reorder the list so that the queue elements are reversed in order.

Prelude

  • Create a character array of size 80 for the string buffer. Declare the array size as a CONSTANT.
  • Use fork to create a new process. See the fork example and the man page (i.e., man 2 fork).
  • Read the string ensuring you do NOT allow a buffer overflow. Investigate fgets, strtok, and strcspn.
  • Use getpid to obtain a PID. You may also find getppid helpful. Consult the man pages.
  • Include header file <unistd.h>.

Output Format

shell> Hi there!
Parent says: PID = 1547, child PID = 1548, parent PID = 1237
Child says:  PID = 1548, parent PID = 1547, 'Hi there!'

Prelude 2

Write a simple shell that reads ONE command, forks a process to execute the command, and waits for the command to complete before printing its exit status.

  • Print a prompt and read a command string from the user, which MAY include spaces.
  • Tokenize the string, creating an args array. You may assume the string is not empty. Use space, tab, and newline characters as delimiters.
  • Fork a process, ensuring you detect and print errors. Use strerror as you did before.
  • In the child process, execute the command using execvp. (A variant of execve that omits the environment and searches in your path for the executable.)
  • In the parent process wait for the child to terminate using waitpid (i.e., reap the child). Print the exit status with WEXITSTATUS.

Output Format

shell> ls -a
[ ls ] (PID: 3052378)
.             Descr.c                       MallocLab
..            Dest.txt                      Midterm.txt
a             Dir                           Notes
...
[* ls *] (Exit: 0)

cscios's People

Contributors

mikewilzn avatar 0x746a6d avatar

Watchers

Christian Shepperson avatar  avatar

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.