码迷,mamicode.com
首页 > 其他好文 > 详细

CSCI 3100 Unix and C

时间:2019-12-03 19:52:43      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:google   sites   微信   inpu   mpi   hand   his   count   user   


Your name:
S number: Homework 3
CSCI 3100 Unix and C
November 4, 2019
1 Process and thread handling.
How to submit?
(a) Zip your source codes and a screenshot (cellphone pictures are OK) for each programming
problem. Make sure to name your file in the format of ”problem1.c” and ”screenshot1.jpg”.
(b) Submit the zip file to Blackboard.
Forking is very useful for applications with multiple simultaneous connections. For example,
modern internet browser like Google Chrome, it creates processes for independent websites,
plugins, etc. In this assignment, you will write a program to simulate how it works.
1.1 Create a program for internet browser simulation. Requirement:
1. It has a loop to receive user’s input.
2. User can either input an URL of a website, a PID or message “exit”.
3. If the input is an URL, use the fork function to create another process.
(a) fork();
(b) For parent process, prints a message “Create a process PID for new website”.
Replace PID to the PID that you get from the fork() function.
(c) For child process, prints a message “You are visiting website URL”. Replace URL
CSCI 3100作业代做、C++程序语言作业调试
to the actual URL you pass to the child process.
(d) For the child process, after printing that message, create an infinite loop to prevent
the child process from exiting until it receives a signal from the parent asking it
to exit.
4. If the input is a PID, send a SIGQUIT signal to the child process and ask it to quit.
You can use the following function to check if the input can be converted to integer:
1 i n t isNumber ( ch a r s [ ] , i n t s i z e )
2 {
3 f o r ( i n t i = 0 ; i < s i z e ; i++)
4 i f ( i s d i g i t ( s [ i ] ) == f a l s e )
5 r e t u r n 0 ;
6
7 r e t u r n 1 ;
8 }
9
1
Your name:
S number: Homework 3
CSCI 3100 Unix and C
November 4, 2019
If the function return 1, then use function atoi() to convert it into integer.
5. If the input is “exit”, quit your program.
Here is an example output:
Figure 1: Sample output
1.2 Create a thread of function “mythread()” in your program
and wait until it finishes. Requirements:
1. Before creating the thread, print a message “A thread is going to be created.” in the
main thread.
2. In the function “mythread()”, print messages “Counting...” 10 times.
3. After executing the thread, print message “Done executing thread.” in the main thread.
1.3 Bonus 20 pts. If you can submit Makefile to compile the problems
above with “make”, you will get 10 pts for each problem.
2

因为专业,所以值得信赖。如有需要,请加QQ99515681  微信:codehelp

CSCI 3100 Unix and C

标签:google   sites   微信   inpu   mpi   hand   his   count   user   

原文地址:https://www.cnblogs.com/simplebluejava/p/11978674.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!