Preview

C coding

Satisfactory Essays
Open Document
Open Document
384 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
C coding
Assignment 1 (FIT5003)
User Manual

Scope:
Create threads based on user input to share the processor time.

Steps:
1. The codes are written in C language compiled in a virtual machine (gcc -lpthread -o soft soft.c).
2. First, the program will give the user the option to input number of threads to be processed 1, 2..., etc using the scanf function.

3. The threads will increment using while loop.
4. After mentioning number of threads the first thread will be created for processing. The user will be asked to enter his/her student ID.
5. The user should enter the value of two integers A and B.
6. Get the modulus of student ID by 3 using if condition in order to achieve the below functionality:
If the mode is equal to (0) then calculate the sum.
Else if, the mode is equal to (1) then calculate the sum of squares.
Finally, if the mode is equal to (2) calculate the factorial.
7. Print the time used for each thread to process individually in seconds using (gettimeofday) function.
8. Also, the program will print the current date, month and time at the end.

Example:
Let’s assume that the use will enter 1170 as his user ID so, 1170 mod 3 which will equal to 0 it will calculate Sum of integers based on A and B entries. Then the program will ask the user to enter A: 25 and B: 50 (25+26+27…. +49) so, the total = 925. The last value is 49 based on the end value (b-1) so, 50 will not be included in the calculation.

Assumption and justification:
1. Allowing the user to enter the value of A and B is more practical than just assigning static value for A and B.
2. Specifying in if condition that input B must be greater than A, according to the condition of the end value (b-1).
3. Because of the size of the program the processor doesn’t require much time to execute and that’s the reason why the output is 0.000000 seconds.

Limitation:
In calculating the factorial and sum of squares if the user entered large numbers (four

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Nt1310 Unit 1 Study Guide

    • 378 Words
    • 2 Pages

    Multiple threads can interfere with each other when sharing hardware resources such as caches or translation lookaside buffers (TLBs). As a result, execution times of a single thread are not improved but can be degraded, even when only one thread is executing, due to lower frequencies or additional pipeline stages that are necessary to accommodate thread-switching hardware.…

    • 378 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 Unit 7 Study Guide

    • 582 Words
    • 3 Pages

    2.Write a program to (a) display a “?” (b) read two decimal digits whose sum less than 10 (c) display them and their sum on the next line. Page: 80…

    • 582 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Mat 540 Week 4 Paper

    • 1775 Words
    • 8 Pages

    A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of the apple.…

    • 1775 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    pt1420 exam review

    • 738 Words
    • 3 Pages

    1 - Design the Program2 - Write the Code3 - Correct Syntax Errors4 - Test the Executable Code…

    • 738 Words
    • 3 Pages
    Good Essays
  • Good Essays

    c. Modify the program of Part b so that at the option of the user, it displays…

    • 300 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    CMIS 102 Homework 3

    • 342 Words
    • 3 Pages

    Program Description - This program will allow a user to input their name and final grades from their courses and calculate their GPA accordingky. The amount of students as well as the amount of classes each student is taking, are undetermined.…

    • 342 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Income Tax

    • 950 Words
    • 11 Pages

    8 Subtract line 7 from line 6. If zero or less, enter -0-. However, if line 7…

    • 950 Words
    • 11 Pages
    Good Essays
  • Satisfactory Essays

    Variable and Meal Price

    • 1236 Words
    • 9 Pages

    10.) Design a subroutine called timesTen. The subroutine should accept an integer argument. When the subroutine is called, it should display the product of its argument multiplied by 10.…

    • 1236 Words
    • 9 Pages
    Satisfactory Essays
  • Satisfactory Essays

    mr shravan

    • 881 Words
    • 4 Pages

    equals to the largest digit of your student ID number or N=5 (if the highest digit of your…

    • 881 Words
    • 4 Pages
    Satisfactory Essays
  • Better Essays

    5. It is capable of executing instructions on its own after the data and program have been fed into its memory.…

    • 4310 Words
    • 17 Pages
    Better Essays
  • Satisfactory Essays

    Ddasd

    • 908 Words
    • 4 Pages

    4.if the clock period of 8085 is 0.2 µs calculate the time required to execute…

    • 908 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    INSTRUCTION: Write TRUE if the statement is correct and FALSE if the statement is incorrect on the space provided before each number.…

    • 824 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Java assignments

    • 272 Words
    • 2 Pages

    4. Write a program that prints prime numbers between 1 to n. Number n should be…

    • 272 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    System Programming

    • 30057 Words
    • 121 Pages

    (SIC) - Machine architecture - Data and instruction formats - addressing modes instruction sets - I/O and programming.…

    • 30057 Words
    • 121 Pages
    Powerful Essays
  • Powerful Essays

    Basics of Computer

    • 3726 Words
    • 15 Pages

    The computer performs basically five major operations of functions irrespective of their size and make. These are 1) it…

    • 3726 Words
    • 15 Pages
    Powerful Essays