بسم الله الرحمن الرحيم
أنا طالبة مبتدأة في مجال البرمجة في نظام اللينوكس
أتمنى منك مساعدتي في حل هاتين المسألتين البسيطة والتي صعب علي حلها لأنني لم أحظى بأحد يشرح لي طريقة كتابة برامج مثل هذه وإن كانت بسيطة أو حتى تافهة
وهذي هي مشكلتي .. حيث أنني مطالبة بتسليم الحل دون أن يشرح لي شيئا من هذا
وآخر موعد للتسليم هو يوم الأحد القادم
أتمنى منك سرعة الرد علي .. ولكم جزيل الشكر والعرفان
المسائل عبارة عن أكواد بلغة السي نكتبها بكومبايلر السي في نظام اللينوكس gcc
المسألة الأولى :
Goal: The goal of this program is to help you understand the process management concepts in UNIX.
Specically, you learn the usage of the following system calls:
fork(): process creation
exec(): replacing a process with another program
kill(): sending a signal to a process
signal(): registering/installing signal catch routines.
Program Description: You write two programs, called P1 and C1. P1 rst creates a process for C1 using
fork() and exec() system calls. After that, P1 continuously issues alarm() system calls and catches and
counts SIGALARM signal. In its SIGALARM catch routine, P1 sends a signal to the child process. The
child process counts the number of SIGALARM signals received from its parent. Upon reaching a specied
number, which is given as an argument in the exec() call, the child process reports the signal count and
terminates itself. The parent process, P1, should always check and report the status of its child. After
noticing its child termination, the parent should report the status of child process before it terminates itself.
Hint: when a child dies, the parent process receives SIGCHLD (or SIGCLD) signal.
المسألة الثانية :
You will write a multithreaded program to short a large integer array. Your application will have a main
thread whose job is to read the data from a file into an array and delegate the sorting function to two
threads. Each created thread will sort half of the array. When both child threads are done with the sorting,
the parent thread will merge these two sorted subarrays and write the sorted array into a file (Hint: for
merge operation, see mergesort in your data structure books). Child threads may use the same sort function
or each may sort its portion of array using different sort algorithms. I leave the decision to you.
Required: You have to use POSIX Pthread library.
أنا طالبة مبتدأة في مجال البرمجة في نظام اللينوكس
أتمنى منك مساعدتي في حل هاتين المسألتين البسيطة والتي صعب علي حلها لأنني لم أحظى بأحد يشرح لي طريقة كتابة برامج مثل هذه وإن كانت بسيطة أو حتى تافهة
وهذي هي مشكلتي .. حيث أنني مطالبة بتسليم الحل دون أن يشرح لي شيئا من هذا
وآخر موعد للتسليم هو يوم الأحد القادم
أتمنى منك سرعة الرد علي .. ولكم جزيل الشكر والعرفان
المسائل عبارة عن أكواد بلغة السي نكتبها بكومبايلر السي في نظام اللينوكس gcc
المسألة الأولى :
Goal: The goal of this program is to help you understand the process management concepts in UNIX.
Specically, you learn the usage of the following system calls:
fork(): process creation
exec(): replacing a process with another program
kill(): sending a signal to a process
signal(): registering/installing signal catch routines.
Program Description: You write two programs, called P1 and C1. P1 rst creates a process for C1 using
fork() and exec() system calls. After that, P1 continuously issues alarm() system calls and catches and
counts SIGALARM signal. In its SIGALARM catch routine, P1 sends a signal to the child process. The
child process counts the number of SIGALARM signals received from its parent. Upon reaching a specied
number, which is given as an argument in the exec() call, the child process reports the signal count and
terminates itself. The parent process, P1, should always check and report the status of its child. After
noticing its child termination, the parent should report the status of child process before it terminates itself.
Hint: when a child dies, the parent process receives SIGCHLD (or SIGCLD) signal.
المسألة الثانية :
You will write a multithreaded program to short a large integer array. Your application will have a main
thread whose job is to read the data from a file into an array and delegate the sorting function to two
threads. Each created thread will sort half of the array. When both child threads are done with the sorting,
the parent thread will merge these two sorted subarrays and write the sorted array into a file (Hint: for
merge operation, see mergesort in your data structure books). Child threads may use the same sort function
or each may sort its portion of array using different sort algorithms. I leave the decision to you.
Required: You have to use POSIX Pthread library.
تعليق