os_cp:2024:prog_assignment
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| os_cp:2024:prog_assignment [2024/05/15 22:24] – utworzono jkonczak | os_cp:2024:prog_assignment [2024/06/05 23:38] (current) – jkonczak | ||
|---|---|---|---|
| Line 18: | Line 18: | ||
| redundancy will lower the grade. | redundancy will lower the grade. | ||
| - | The deadline for the assignment is **02.06.2024** (AoE). Please send the | + | The deadline for the assignment is 02.06.2024 (AoE). Please send the |
| solutions to me as an attachment to an e-mail message with the subject | solutions to me as an attachment to an e-mail message with the subject | ||
| beginning with '' | beginning with '' | ||
| + | |||
| + | **The tests that I used to tell if your code behaves as expected are available [[https:// | ||
| <code c header.h> | <code c header.h> | ||
| Line 70: | Line 72: | ||
| * The identifiers shall be consecutive numbers starting from 0. | * The identifiers shall be consecutive numbers starting from 0. | ||
| * Identifier 0 must always be the main thread. | * Identifier 0 must always be the main thread. | ||
| + | * | ||
| + | * (clarification added on 28 May) thread identifiers must not be | ||
| + | * reused; when a thread with an identifier ID terminates, no new | ||
| + | * thread may get the identifier ID. | ||
| | | ||
| * Each thread must have a message queue in that at most | * Each thread must have a message queue in that at most | ||
| Line 181: | Line 187: | ||
| <code c> | <code c> | ||
| #include " | #include " | ||
| + | #include < | ||
| #include < | #include < | ||
| #include < | #include < | ||
| Line 187: | Line 194: | ||
| struct thread_msg{ | struct thread_msg{ | ||
| - | | + | |
| char * txt; | char * txt; | ||
| }; | }; | ||
| Line 252: | Line 259: | ||
| thread_gather(senders, | thread_gather(senders, | ||
| printf(" | printf(" | ||
| + | thread_msg_dec_use_count(msgs[0]); | ||
| + | thread_msg_dec_use_count(msgs[1]); | ||
| | | ||
| // send a message to the main thread | // send a message to the main thread | ||
| Line 277: | Line 286: | ||
| void thread_msg_dec_use_count(thread_msg* msg){ | void thread_msg_dec_use_count(thread_msg* msg){ | ||
| - | if(!msg-> | + | if(!--msg-> |
| free(msg-> | free(msg-> | ||
| free(msg); | free(msg); | ||
os_cp/2024/prog_assignment.1715811842.txt.gz · Last modified: (external edit)