Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. A better explanation on pipes, parents, and childs and tips to code

A better explanation on pipes, parents, and childs and tips to code

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
helptutorialquestion
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Endomlic
    wrote on last edited by
    #1

    I was given a HW assignment that I am having a lot of trouble on. I must have missed the day the teacher explained all of this because I have nothing on this material other than google...It's not even in the text. here is the problem Write a C-program that does the following: The program first creates a single pipe, using the pipe() system call. It then forks a child process using the fork() call. The goal is to share the work of counting numbers that are multiples of 3 and 5 from the set of integers from 1-10000. The parent process executes the for-loop (from 1-10000) and takes the responsibility for counting all multiples of 5. All numbers that are not multiple of 5 are passed through the pipe to the child process to be inspected and counted if they are multiples of 3. Note: Only the parent process will implement the for-loop from 1-10000. After the processes have completed their work, both, parent and child will print out a corresponding message together with their corresponding process-id. The child then uses the pipe to send its result to the parent. Upon reading the number of multiples of 3 from the pipe, the parent will print out the complete response to the user (i.e., count of multiples of 3 and 5) and wait for the child to exit properly and exit. What happens if the child process is executing significantly slower than the parent process, i.e., what if the parent wants to read from the pipe while the child process has not had a chance to read all multiples of 3 from it? Describe the problem! Describe how you simulated this problem! What do you need to do to avoid this problem? Show your solution! could anyone give me any ideas on how to go about solving this, and how I'm supposed to work with communicating these pipes?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups