posted Dec 21, 2018, 7:17 AM by JonAlf Dyrland-Weaver
Create a forking server system. - start with the persistent server system.
- add/modify pipe_networking.c/h so that the server side handshake is broken up appropriately.
- modify the server program to work as a forking server
- leave the client alone
- you should submit pipe_networking.c/h as well as both your server and client .c files (and a makefile, as always!)
GitHub link https://github.com/mks65/forking_server.git |
posted Dec 19, 2018, 7:36 AM by JonAlf Dyrland-Weaver
Starting with working handshake code from the previous assignment: - COPY your files, do not modify the files in your current handshake repository.
- Modify there server and client programs:
- Handshake
- Prompt user for input
- Send input to server.
- Get response from server and display it to user
- Repeat steps 2-4 until interrupted (ctrl-c).
- Handshake
- Get data from client
- "Process" data - do something interesting to it
- Send processed data back to client
- Repeat 2-4 until the client exits
- When the client exits, the pipes will close automatically
- Reset for a new handshake
- Include a signal handler for SIGINT that will remove the WKP
GitHub link https://github.com/mks65/persistent_server.git |
posted Dec 18, 2018, 8:05 AM by JonAlf Dyrland-Weaver
[
updated Dec 18, 2018, 8:06 AM
]
- Check out the files on https://github.com/mks65/networking
- Fill in the function definitions for
server_handshake and client_handshake in pipe_networking.c. - These should do everything needed to establish a 3-way handshake between the client and server.
- make sure you include diagnostic print messages in your functions.
- make and test
- You should not modify any other files for this assignment.
Github clone link: https://github.com/mks65/handshake.git |
posted Dec 12, 2018, 6:56 AM by JonAlf Dyrland-Weaver
This will be due Friday, 12/14
With your table buddy, write a telephone style game! It will use a semaphore to control access to a file and shared memory.
The main program should work as follows: - Print a message this it will check if resources are available.
- When they are, display the last line added to the story (or none, if it is new).
- Prompt the user to enter the next line
- Update the story
- quit
This game will require 2 files - A control program
- Take a command line argument to determine if it is creating or removing the resources or viewing the story.
- If creating (command line argument:
-c ): - Should make the shared memory, semaphore and file (open the file with the truncate flag).
- Set any values that are needed.
- If removing (command line argument:
-r )
- Remove the shared memory, the semaphore and the story.
- Display the full contents of the story.
- This should wait until the semaphore is available.
- If viewing (command line argument:
-v ) - Output the contents of the story file.
- This mode does not need to interact with the semaphore
- A main writing program
- Will attempt to access the resources using the semaphore
- Once in, it should display the last line added to the file (use shared memory to contain the size of the last line).
- Prompt the use for the next line.
- Once a new line is read, write that to the file, update the shared memory and then release the semaphore
- You do not need a run target in your makefile
github link: https://github.com/mks65/semaphone.git |
posted Dec 4, 2018, 6:39 AM by JonAlf Dyrland-Weaver
Shared memory is a thing, and it's exactly what it sounds like. You can learn more about it here:
Once you've learned a thing or two, write a program that does the following: - Connects or creates a shared memory segment large enough to hold a 200 character string.
- Displays the contents of the shared memory.
- If the segment was just created, instead show a message saying as much.
- Ask the user if they want to change the data in the segment.
- If yes, prompt the user to enter a new string and write that to the segment.
- Ask the user if they want to delete the segment, if yes, then delete it.
Github submission link https://github.com/mks65/shmegegge.git |
posted Nov 16, 2018, 7:48 AM by JonAlf Dyrland-Weaver
Write a c program that does the following: - Forks off 2 child processes
- Child process instructions:
- At the start print its pid
- Sleep for a random number of seconds in the range [5, 20]
- Each child should sleep for a (potentially) different amount of seconds
- At the end print a message that it is finished
- Parent process instructions
- Before forking, print out some initial message
- After the fork, wait for any child to finish
- Once a child has finished, print out the pid of the completed child as well as how many seconds it was asleep for.
- Do not run any kind of timer, think about how the child could send this information back to the parent.
- Print a message that the parent is done and then end the program
- The other child might still be running, that's ok.
github clone link https://github.com/mks65/forkin.git |
posted Nov 14, 2018, 5:50 AM by JonAlf Dyrland-Weaver
With your table buddy, do the following:
strep is a function in string.h used to help parse stringsstrsep( <SOURCE>, <DELIMETER> ) - Locates the first occurrence of any character in the DELIMITER string and replaces it with NULL
- Returns the beginning of the original string
- sets the source string pointer to point to the index 1 byte after the location of the new NULL
- Since the source variable's value is changed, it must be a pointer to a string.
- To test it out, try the following code:
char line[100] = "woah-this-is-cool";
char *s1 = line;
printf("[%s]\n", strsep( &s1, "-" ));
printf("[%s]\n", s1);
Write a function that uses strep to parse a line of arguments - Use the following header:
char ** parse_args( char * line ); - It should take a string with the command line invocation of a program (like
"ls -a -l" ) - Note that there is a
" " between each argument
- Return an array of pointers to each individual argument in the parameter string, that could be used for
execvp() - For example, the following code should work (assuming all variables are declared appropriately:
- You can make the following assumptions:
- There is only 1 space between each argument in the original string
- The original string contains no more than 5 arguments
- The original string is correctly formatted
github link: https://github.com/mks65/parse_args.git |
posted Nov 8, 2018, 6:01 AM by JonAlf Dyrland-Weaver
Write a C program with the following features: - Runs constantly inside a forever while loop.
- Print out the process' PID inside the loop.
- Use the
sleep(1) function to have the program wait 1 second between inner loop iterations. - Catch the following signals
- SIGINT
- Before exiting, append a message to a file noting that the program exited due to SIGINT
- To make your program quit, look up the
exit function.
- SIGUSR1
- Print out the PID of the parent process.
- Should not cause the program to exit.
github link https://github.com/mks65/signals.git |
|
posted Nov 1, 2018, 7:04 AM by JonAlf Dyrland-Weaver
[
updated Nov 2, 2018, 5:45 AM
]
New and improved instructions: - Your program should handle user input as follows:
- If a command line argument is entered, use that as the directory to scan.
- If not, the program should ask the user to enter a directory to scan.
- In either case, don't assume your user knows what they are doing, if an invalid directory is entered, take reasonable action (*ahem* errno *cough cough*)
With your *new* table buddy, write a program that will gather various information about a directory, specifically: - list all the files in the directory
- specify which files are directories (if any)
- show the total size of all the regular files the directory
- note that you do not have to recursively go through any subdirectories to find their size for this part (unless you want to, but that is not a simple task)
- Have the program scan the current directory
- Possible enhancements:
- Recursively list the files in any subdirectories, update the total to include the total size of subdirectories
- Print out the size in a more readable format (like using KB, MB, GB for -byte prefixes)
Github link: https://github.com/mks65/dirinfo.git
Below is sample output, yours may differ, but as long as it presents the information requested above you will receive full credit. $ ./a.out
Statistics for directory: .
Total Diectory Size: 13453 Bytes
Directories:
.
..
Regular files:
a.out
dirinfo.c
dirinfo.c~
dirstuff.c
dirstuff.c~
$ ./a.out
Statistics for directory: .
Total Diectory Size: 17766 Bytes
Directories:
.
..
dir
structRW
Regular files:
a.out
error.log
filelist
files.c
read.c
ReadTest
redirect.c
redirect.c~
redirect_full.c
redirect_full.c~
redirTest
statfiles.c
statfiles.c~
write.c
WriteTest
|
|
posted Oct 30, 2018, 5:32 AM by JonAlf Dyrland-Weaver
There is a function called stat . It is used to get information about a file. With your table buddy, write a program that uses stat to display the following information about a file: - file size
- mode (permissions)
- time of last access (displayed in the following format:
Fri Oct 28 09:03:01 2016 - Note
- You may hardcode the file that your program uses, make sure the program works when I download and run it.
- If only there were some file that you know I will have and where it is... hmm...
Once you have that, try the following: - Modify the size so it is printed out in human readable form (that is using B, KB, MB, GB).
- You may want to look into the
sprintf function to help.
- Attempt to print out the permissions in ls -l form, ignoring the early bits that include the file type information
- Permissions are of type
mode_t , which is an integer type. - The permissions section of the mode is stored in the last 9 bits of the
mode_t data type.
Github clone url: https://github.com/mks65/stat.git |
|