Questions
1.What are two differences between user-level threads and kernel-level threads? Under what circumstances is one type...

1.What are two differences between user-level threads and kernel-level threads? Under what circumstances is one type better than the other?

2.Describe the actions taken by a kernel to context switch between kernel level threads.

3.What resources are used when a thread is created? How do they differ from those used when a process is created?

4.Provide two programming examples in which multithreading provides better performance than a single-threaded solution.   

5.Assume an operating system maps user-level threads to the kernel using the many-to-many model and the mapping is done through LWPs. Furthermore, the system allows developers to create real-time threads. Is it necessary to bind a real-time thread to an LWP? Explain

6.Windows Vista provides a lightweight synchronization tool called slim reader–writer locks. Whereas most implementations of reader–writer locks favor either readers or writers, or perhaps order waiting threads using a FIFO policy, slim reader–writer locks favor neither readers nor writers, nor are waiting threads ordered in a FIFO queue. Explain the benefits of providing such a synchronization tool.

In: Computer Science

Write a value returning function called isPrime. This function accepts integer number as parameter and checks...

Write a value returning function called isPrime. This function accepts integer number as parameter and checks whether it is prime or not. If the number is prime the function returns true. Otherwise, function returns false. A prime number is the number that can be divided by itself and 1 without any reminder, i.e. divisible by itself and 1 only.

DO THIS USING C++ LANGUAGE .WITH UPTO CHAPTERS 5 (LOOP).

In: Computer Science

Outside of main declare two constant variables: an integer for number of days in the week...

Outside of main declare two constant variables: an integer for number of days in the week and a double for the revenue per pizza (which is $8.50). Create the function prototypes.

Create main

Inside main:

  1. Declare an integer array that can hold the number of pizzas purchased each day for one week.
  2. Declare two additional variables one to hold the total sum of pizzas sold in a week and one to hold the average pizzas sold per day
  3. Using an appropriate loop, ask the user to enter in the number of pizza for each day
    1. The program must test the entry value.
    2. If the number entered is negative, the program must display an error message and allow for the reentry of the value for that day. The program will continue to ask for a valid response until a valid response is entered.
    3. If the number is valid (greater than or equal to zero), the program will then prompt for the next value until the loop ends.
    4. Extra Credit will be given if the validation test is done via a function call.
  4. Send the array to a function that displays a title for the report as well as the number of pizzas sold for each day.
  5. Send the array to a function that calculates the sum total of pizzas sold for the week; the function returns the sum total back to main().
  6. Send the array to a function that calculates the average number of pizzas sold for the week; the function returns the average back to main().
  7. Display the following:
    1. The total number of pizzas sold for the week
    2. The average number of pizzas sold per day
    3. The total revenue from the pizza sold for the week
    4. The average revenue per day
  8. Display a thank you/goodbye message.
  9. Comment your code.

Submit the .cpp file and a screen shot in Canvas

Screen Shots:

please write the code for c++

In: Computer Science

4. Suppose that the following processes arrive for execution at the times indicated. Each process will...

4. Suppose that the following processes arrive for execution at the times indicated. Each process will run for the amount of time listed. In answering the questions, use non-preemptive scheduling, and base all decisions on the information you have at the time the decision must be made.

Process          Arrival Time           Burst Time

P1                           0.0                                    8

P2                           0.4                                   4

P3                           1.0                                    1

a. What is the average turnaround time for these processes with the FCFS scheduling algorithm?

b. What is the average turnaround time for these processes with the SJF scheduling algorithm?

c. The SJF algorithm is supposed to improve performance, but notice that we chose to run process P1 at time 0 because we did not know that two shorter processes would arrive soon. Compute what the

average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is used. Remember that processes P1 and P2 are waiting during this idle time, so their waiting time may increase. This algorithm could be known as future-knowledge scheduling.

In: Computer Science

1. What are some common risks, threats, and vulnerabilities found in the Remote Access Domain that...


1. What are some common risks, threats, and vulnerabilities found in the Remote Access Domain that must be mitigated through a layered security strategy?
2. What default configuration should be placed on host-based firewalls when accessing the network remotely?
3. What risks, threats, and vulnerabilities are introduced by implementing a remote access server?
4. What is a recommended best practice when implementing a remote access policy server user authentication service?
5. What is a Remediation LAN?

In: Computer Science

Can you fix my code and remove the errors in java language. public class LinkedStack<T> implements...

Can you fix my code and remove the errors in java language.

public class LinkedStack<T> implements Stack<T> {

private Node<T> top;

private int numElements = 0;

public int size() {

return (numElements);

}

public boolean isEmpty() {

return (top == null);

}

public T top() throws StackException {

if (isEmpty())

throw new StackException("Stack is empty.");

return top.info;

}

public T pop() throws StackException {

Node<T> temp;

if (isEmpty())

throw new StackException("Stack underflow.");

temp = top;

top = top.getLink();

return temp.getInfo();

}

public void push(T item) {

Node<T> newNode = new Node();

newNode.setInfo(item);

newNode.setLink(top);

top = newNode;

}

@Override
public T peek() throws StackException {
return null;
}

@Override
public void clear() {

}

@Override
public int search(T item) {
return 0;
}

}

////////////////////////////////////////////////////

public interface Stack<T> {

public int size(); /* returns the size of the stack */ public boolean isEmpty(); /* checks if empty */

public T top() throws StackException;

public T pop() throws StackException;

public void push(T item) throws StackException;

public T peek() throws StackException;

public void clear();

public int search(T item);

}


class StackException extends RuntimeException {

public StackException(String err) {

super(err);

}

}

}

//////////////////////////////////////////////////

public class Node<T> {

public T info;

private Node<T> link;

public Node() { }

public Node (T info, Node<T> link) {

this.info = info;

this.link = link;

}

public void setInfo(T info) {

this.info = info;

}

public void setLink(Node<T> link) {

this.link = link;

}

public T getInfo() {

return info;

}

public Node<T> getLink() {

return link;

}

}

postfixExpression = empty String

operatorStack = empty stack

while (not end of infixExpression) {

symbol = next token

if (symbol is an operand)

concatenate symbol to postfixExpression

else { // symbol is an operator

while (not operatorStack.empty() &&

precedence(operatorStack.peek(),symbol) { topSymbol = operatorStack.pop();

concatenate topSymbol to postfixExpression;

} // end while

if (operatorStack.empty() || symbol != )’'/U2019' ) operatorStack.push(symbol);

else // pop the open parenthesis and discard it topSymbol = operatorStack.pop();

} // end else

} // end while

// get all remaining operators from the stack

while (not operatorStack.empty) {

topSymbol = operatorStack.pop();

concatenate topSymbol to postfixExpression

} // end while

return postfixExpression

//////////////////////////////////////////////////

import java.util.*;
class StackLinklist {
Node head=new Node(); //head pointer of linked list

public boolean isEmpty() //check whether stack empty or not
{
if(head == null)
return true;
return false;
}

public void push(char x) //add element eo stack
{
Node t=new Node();
if (t != null) {
t.op=x;
t.next=head;
head=t;
}
else{
System.out.print("Stack overflow"); //heap overflow
return;
}
}

public char topmost() // return top most caharater of stack
{
if (!isEmpty()) {
return head.op;
}
else {
System.out.println("Stack is empty");
return '\0';
}
}


public char pop() // remove the element
{
// underflow
if (head == null) {
System.out.print("\nStack Underflow");
return '\0';
}
char chp=head.op;
head = (head).next;
return chp;
}


private class Node { // class of linked list which denotes eac node
char op;
Node next;
}

}
class InfixTOPostfixConversion
{


static String infixToPostfix(String str)
{
String r ="";
StackLinklist stack = new StackLinklist();
for (int i = 0; i<str.length(); ++i)
{
char c = str.charAt(i);
if (c == '(') //if opening bracket occur,add it into stack
stack.push(c);

else if (c == ')') //case for closing bracket
{
while (!stack.isEmpty() && stack.topmost() != '(')
r+= stack.pop();

if (!stack.isEmpty() && stack.topmost() != '(')
return "invalid expression";
else
stack.pop();
}

// case of operands
else if((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' &&c<='9'))
r+=c;

else // case of operators, operartors will be poped baed on precedence
{
while (!stack.isEmpty() && Precedence(stack.topmost()) >= Precedence(c)){
if(stack.topmost() == '(')
return "invalid expression";
else
r+= stack.pop();
}
stack.push(c);
}

}
while (!stack.isEmpty()){
if(stack.topmost() == '(')
return "invalid expression";
r+= stack.pop();
}
return r;
}


public static void main(String[] args)
{
Scanner ob=new Scanner(System.in);
while(true){
int flag=0;
System.out.println("press 1 to enter infix string, press 2 to exit");
int n=ob.nextInt();
switch(n){
case 1:
System.out.println("Enter the infix expression");
ob.nextLine();
String s=ob.nextLine();
String r=infixToPostfix(s);
if(r.equals("invalid expression"))
System.out.println(r);
else
System.out.println("Postfix Expression of given expression is "+r);
break;
case 2:
flag=1;
break;
default:
System.out.println("please enter avalid input");
}
if(flag==1)
break;
System.out.println();
System.out.println();
}

}

static int Precedence(char ch) // function for deciding operator precedence
{
int p=-1;
if(ch=='^'){
p=1000;
}
else if(ch=='*'){
p=500;
}
else if(ch=='/'){
p=500;
}
else if(ch=='+'){
p=100;
}
else if(ch=='-'){
p=100;
}
return p;
}
}

In: Computer Science

Explain the concept of a Remediation Server and traffic separation as it relates to remote access....

Explain the concept of a Remediation Server and traffic separation as it relates to remote access.

What is a VPN? Distinguish between VPN server, VPN client, VPN router, and Secure Sockets Layer (SSL) VPNs.

What is the difference between a tunnel-mode VPN and a split-tunneling VPN?

According to the Remote Access Policy STIG, what personally owned devices are considered acceptable to perform privileged (administrative) tasks on a DoD network?

When connected to a public network or shared public Internet access point, what are some precautions that remote users should take to ensure confidentiality of communications?

In: Computer Science

which question is incomplete these question given like they are and i have to answer them....

which question is incomplete these question given like they are and i have to answer them. These are Java questions.

Q1. //Write an iterative method to count long book in the linked list. Assume that book has               method

// Boolean isLong () that returns true if book is long and returns false otherwise.

Public int countLongBooks ()

{

Q2. //Recursive method to add a new node (with myBook as data) at the rear of the list

Public void addToRearRec(Book myBook, Node first)

Q3. //Recursive method returns longest Book in the non-empty linked list. First refers to the first node in the linked l

// list.

    Public Book longestBook ( Node first)

{

Q4. Determine the outcome of the following code if NumberFormatException happened within the try block.

Try

{

    //some code

}

Catch (Number FormatException e)

{

      System.out.println(“Example ne”);

}

Catch (stringIndexOutOfBoundsException e)

{

      System.out.println(“Example two”);

}

Finally

{

       System.out.println(“Finally is dine”);

}

System.out.println(“The next”);

Q5. Determine the outcome of m(4) invocation?

Public void m(int n)

{

If. (n <= 1

System.out.print(“A”);

Else

{

       m(n-1);

       m(n-2);

}

}

Q 6.  

Write “C” next the statements that are correct?

a). Interface is java class that cannot be instantiated.

b). Interface is java class containing constants / or abstract methods.

c). Interface is an abstract class.

d). Interface is java structure containing constants and / or abstract methods.

Q7. Complete code for recursive method which returns shortest person in the nonempty list.Assume that only first n elements in the list have been assigned their values.person class has method getHight().

Public person shortestPersonRec(Person[] list, int n)

{

In: Computer Science

Need a c++ program to generate a random string of letters between 8 and 16 characters.

Need a c++ program to generate a random string of letters between 8 and 16 characters.

In: Computer Science

Test Memory Usage on the Text File Reversing Problem (1 mark) Test the performance of your...

Test Memory Usage on the Text File Reversing Problem (1 mark)
Test the performance of your Stack implementation on file reversing task. The code below is to reverse a text file using the stack. It has three lines missing, and you need to complete it. Then you submit it on our marking site here. You need to change the stack capacity according to input data size. On average each line has about 11 words. Our site prints out the total computer memory usage by your program when it runs on 5 data sets of different sizes.
The total memory usage from the submission site is

static String[] reverse(String filename) throws Exception{
       Scanner scanner = new Scanner(new File(filename)).useDelimiter("[^a-zA-Z]+");
       Stack2540Array stack = new Stack2540Array();
       while (scanner.hasNext())
           stack.push(scanner.next().toLowerCase());
       String[] rev = new String[stack.size()];


/* for (int i = 0; i < stack.size(); i++) {
           rev[i] = stack.pop();
       } */


       return rev;
   }

The code for Stack2540Array cannot be modified:

import java.io.*;
import java.util.*;

public class Stack2540Array {
   int CAPACITY = 128;
   int top;
   String[] stack;
  
   public Stack2540Array() {
       stack = new String[CAPACITY];
       top = -1;
   }

   public int size() {       return top + 1;   }
   public boolean isEmpty() {       return (top == -1); }

   public String top() {
       if (top == -1)
           return null;
       return stack[top];
   }
      
   public void push(String element) {
       top++;
       stack[top] = element;
   }

   public String pop() {
   if (top == -1) {
return null;
}
   else {
return stack[top--];
}
   }
}

The lines are added as comments, but the output shows: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 128 out of bounds for length 128. Your Stack and reverse() can run, but the result is not correct. Can you please fix the error in the code?

* The complete program is not available as we are supposed to work with code fragments.

In: Computer Science

“Software Integration” is a procedure of merging two or more different software structures either mono-directional or...

“Software Integration” is a procedure of merging two or more different software structures either mono-directional or bi-directional so that information and functionality flow among that system efficiently.

Using your own words, explain “Why there is a need for Software Integration” and list some cases where “Software Integration” can help the organizations.

In: Computer Science

Write a jQuery click event handler for all tags within elements. In the handler, output the...

Write a jQuery click event handler for all tags within

elements. In the handler, output the src attribute of the image to the console.

In: Computer Science

Show how the Shell sort algorithm sorts the array {36, 14, 27, 40, 31, 17, 5,...

Show how the Shell sort algorithm sorts the array {36, 14, 27, 40, 31, 17, 5, 9, 38, 22, 11}. Trace through the algorithm. Must show the operation of the algorithm in details.

In: Computer Science

I'm in a intro to programming class using C++. In some examples in my book, they...

I'm in a intro to programming class using C++. In some examples in my book, they use the letter ' i ' to do certain things like a 'for loop'. I was looking around the internet and I can't seem to find what that specific letter does. In all the websites I went to about operators it wasn't listed. Do I need to define it? Or just use it like it is?

Example: for(int i = 0; i < 4; i++)

In: Computer Science

a.why do we use LWP(light weight process)? b. Virtualization is widely employed in Distibuted system .State...

a.why do we use LWP(light weight process)?

b. Virtualization is widely employed in Distibuted system .State and briefly describe or diagram the three types of virtual systems.Describe the advantages of virtualization and disadvantages of virtualization.

yes . 3 types of virtualization

In: Computer Science