Ask DOT NET Expert

Assignment

Part I:

1. The following is the C# sample code that shows two threads use mutex to communicate. Note mutex is a simplified semaphore.

Refer to this piece of sample code, write a program that conduct the followings:

(1) It contains two thread, t1 and t2;
(2) t1 and t2 share a variable, myNum;
(3) When myNum is empty (use 0 to show empty), t1 will generate a random number between 1 and 99, and save to myNum;
(4) When myNum is not empty, t2 will get this number and save it to an array, myNumArray, in ascending order.
(5) After t2 insert a new number in myNumArray, it also shows the result on screen.

// mutex sample code
using System;
using System.Collections.Generic; using System.Linq;
using System.Text; using System.Threading;

class Test
{
// Create a new Mutex. The creating thread owns the
// Mutex.
private static Mutex mut = new Mutex(true); private const int numIterations = 1; private const int numThreads = 2;

static void Main()
{
// Create the threads that will use the protected resource. for (int i = 0; i < numThreads; i++)
{
Thread myThread = new Thread(new ThreadStart(MyThreadProc)); myThread.Name = String.Format("Thread{0}", i + 1); myThread.Start();
}

// Wait one second before allowing other threads to
// acquire the Mutex.
Console.WriteLine("Creating thread owns the Mutex."); Thread.Sleep(1000);

Console.WriteLine("Creating thread releases the Mutex.\r\n"); mut.ReleaseMutex();

//Console.ReadKey();

}

private static void MyThreadProc()
{
for (int i = 0; i < numIterations; i++)
{
UseResource();
}
}

// This method represents a resource that must be synchronized
// so that only one thread at a time can enter. private static void UseResource()
{
// Wait until it is safe to enter. mut.WaitOne();

Console.WriteLine("{0} has entered the protected area", Thread.CurrentThread.Name);

// Place code to access non-reentrant resources here.

// do work here!! Thread.Sleep(500);

Console.WriteLine("{0} is leaving the protected area\r\n", Thread.CurrentThread.Name);

// Release the Mutex. mut.ReleaseMutex();
}
}

Part II: Login to Linux (Hyper-v Virtural machine), study Linux and following the following questions.

1. Which of these is a UNIX command which will list the contents of a directory?

A. pwd
B. ls
C. list
D. files
E. directory

2. To make a new directory, you would use which command?

A. directory
B. create
C. make
D. mkdir
E. dirmk

3. To remove a directory, you would use which command?

A. remove
B. erase
C. delete
D. deldir
E. rmdir

4. The command which terminate a process is called:

A. copy
B. file
C. filecopy
D. cp
E. kill

5. Partial output of ls -F command is: Work1*
Work2/

Which of the following is correct?

A. Work2 is executable, Work1 is a directory
B. Both are executable
C. Work1* and Work2/ are two files
D. Work1 is executable, Work2 is a directory
E. None of above

6. To check the process status, which command you would use:

A. ps
B. left
C. cat
D. quotas
E. disk

7. The command, makedir, will create a sub-directory. True or false?

A. True
B. False

8. is the command that changes the file permission.

A. pr
B. top
C. chmod
D. head

10. The command will display the absolute pathname for the directory that you are wokring in.

A. dir
B. whereami
C. pwd
D. ls

11. In Fedora 20, a regular user, john, wants to become root user and do some administration tasks. Which of the following should he use?

A. root
B. super
C. admin
D. su root

12. In Fedora 20, which of the following display process state dynamically?

A. ps
B. top
C. more
D. cat

13. In Fedora 20, a regular user, john, wants to check whether a program, DemoApp, is running or not. Which of the following should he use?

A. find DemoApp
B. whereis DemoApp
C. man DemoApp
D. ps -ax

14. In Fedora 20, a regular user, john, wants to check the options for ps command. He type man ps

Which of the following will terminate man command?

A. c
B. q
C. x
D. z

DOT NET, Programming

  • Category:- DOT NET
  • Reference No.:- M92205430
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in DOT NET

Assignment specificationthis assignment is split into two

ASSIGNMENT SPECIFICATION This assignment is split into two documents. 1. Assignment Specification. This document contains the specification for what you will be required to do. 2. Assignment Addendum. This document conta ...

Scenariouser modelling inc would like to organize a series

Scenario User Modelling Inc. would like to organize a series of conferences focusing on research topics in the area of user adaptive systems and personalization. They need to organize annual conferences for researchers a ...

Casewe sell pdfs from our site and pdfs can be ordered from

Case We sell pdf''s from our site and pdfs can be ordered from the site by selecting a book, putting it in a shopping cart, then signing in with a password or as a guest, and then checking out. For some reason, when a pu ...

Summarythis assessment requires you to develop a simple

Summary This assessment requires you to develop a simple text editor with a basic offline user login. It is a windows application that will allow new uses to be added, existing users to login, and to create/save/edit tex ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As