cs241fa09hw1-solutions - CS241,Homework#1,Fall2009...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 241, Homework #1, Fall 2009 NetID: _________________ CS 241, Homework #1, Fall 2009 Name: ______ ANSWER KEY __________      ( and place your NetID on every sheet! ) INSTRUCTIONS This homework is  INDIVIDUAL WORK .  This homework  SHOULD NOT  be done with your MP  team. Please  TYPE  your homework solutions. Handwritten solutions  WILL NOT  be graded. Please  STAPLE  all sheets together. And type your NetID on  EVERY  stapled sheet. Homework is due  IN-CLASS,   AT THE BEGINNING OF CLASS (11:00am)  on Monday, October  12, 2009.  Since solutions will be discussed during class, no late submissions are allowed. GRADING RUBRIC : Multiple Choice /10 Function Call /6 Missing Code /4 Total /20 Grade: Grader: Multiple Choice Questions The following C code compiles, but may contain some run-time errors: char * foo(char *s) { char *t = (char *)malloc(strlen(s) * sizeof(char)); int i; for (i = 0; i < strlen(s); i++) strncat(t, s + i, 1); return t; } 1. Which of the following is TRUE about the function foo()? a. The function does not always allocate enough heap memory to store the response string.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
NetID: _________________ b. The function relies on default value of allocated memory that may lead the function to access  memory beyond the end of its allocated space. c. The function returns a reference to memory allocated to stack memory in the function’s stack  frame and cannot be read by the caller of the function. d. Both A and B e. Both A and C 2. TRUE or FALSE: The system resources required to create and maintain a thread ARE GREATER  THAN the system resources required to create and maintain a process. a. True b. False 3. Which of the following scheduling algorithms will have the LONGEST average response time after  many jobs are queued and ran to completion? a. Round Robin with a quantum of much less than the shortest job b. Round Robin with a quantum of longer than the longest job c. Shortest Job First (SJF) d. Preemptive Shortest Job First (PSJF) e. First Come First Serve (FCFS) 4. TRUE or FALSE: Given enough binary mutexes, it IS POSSIBLE to create a counting semaphore but  given enough counting semaphores it IS NOT POSSIBLE to create a binary mutex. a.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/28/2011 for the course CS 241 taught by Professor Campbell during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 8

cs241fa09hw1-solutions - CS241,Homework#1,Fall2009...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online