Chinese And Japanese Case Studies

    

Start by reading and following these instructions:

1. Quickly skim the questions or assignment below and the assignment rubric to help you focus.

2. Read the required chapter(s) of the textbook and any additional recommended resources. Some answers may require you to do additional research on the Internet or in other reference sources. Choose your sources carefully.

3. Consider the discussions and any insights gained from it.

4. Create your APA formatted essay-style submission, with references, be sure to cite your sources and check your spelling.

Assignment:

Complete the following :

  • Chinese case study #1
  • Japanese case study #1

Write a 3-4 page APA essay, using two scholarly sources in addition to the textbook.

Process And Threads

For this first assignment, you won’t be writing code; instead, you will be reading and executing the given below codes. Read the README instruction below for directions on how to compile and link the programs. Submit your answer in writing onto Blackboard.

  • Experiment 1. Thread and Process Creation
    Study the programs thr_create.c and fork.c. These programs measure the average time to create a thread using thr_create() and to create a process using fork(). Compile and execute the programs. What do you conclude from this experiment? Describe the reasons for the difference in timings.
  • Experiment 2. Processes vs Threads
    Study the two programs thr_shared.c and proc_shared.c. These programs are identical except that one uses threads and the other uses processes. Compile and execute the programs. What do you conclude from this second experiment? Explain the reason for the difference in behavior.
  • Experiment 3: The Update Problem
    Study the programs shared_data.c and SharedData.java. In these examples, multiple threads are both updating (i.e., modifying) a shared variable. Compile and execute both. Are the programs behaving “correctly”? What do you conclude from this experiment?
    README Instructions
  • Run the program on Linux platform.
  • To compile and run a C program (e.g., thr_create.c):
    gcc -o thr_create thr_create.c -lpthread thr_create
  • To build and run a classfile from the java code: javac SharedData.java
    java SharedData

page1image63834912 page1image63835200 page1image63835488 page1image63835776 page1image63836128 page1image63836416

Submission Guidelines and Requirements

  • Submit your answers for all the experiments as a PDF file onto Blackboard
  • Include your name, UCM ID and Certification statement in your solution:
    //Your name
    // Your UCM ID
    //Certificate of Authenticity: I certify that the codes/answers of this assignment are entirely my own work.

thr_create.c

page2image105196192

#include <sys/time.h> #include <stdio.h> #include <pthread.h> #include <errno.h> main()

{
struct timeval start,end; long forktime;
double avgtime; pthread_t last_thread; int i;
int iters = 250;
void *null_proc();

gettimeofday(&start,NULL);

for (i = 0; i < iters – 1; i++) /* create (iters-1) threads */ pthread_create(&last_thread,NULL,null_proc,NULL);

pthread_create(&last_thread,NULL,null_proc,NULL); /* create last thread */ gettimeofday(&end,NULL);

pthread_join(last_thread, NULL); /* wait for last thread */ forktime = (end.tv_sec – start.tv_sec)*1000000 +

(end.tv_usec – start.tv_usec); avgtime = (double)forktime/(double)iters;

printf(“Avg thr_create time = %f microsecn”, avgtime); }

void *null_proc() {}

for (i = 0; i < iters; i++) /* create iters processes */ {

if ((pid = fork()) == 0) /* child process */ {

null_proc();

exit(1); }

else if (pid == -1) {

/* error */

printf(“error %dn”,errno);

exit(-1); }

else /* parent process */ continue;

}

/* only parent process reaches this point */ gettimeofday(&end,NULL);
for ( i = 0; i < iters; i++) /* have to do a wait for each child */ wait(&status);
forktime = (end.tv_sec – start.tv_sec)*1000000 +

(end.tv_usec – start.tv_usec); avgtime = (double)forktime/(double)iters;

printf(“Avg fork time =%f microsecn”, avgtime);

} null_proc() {
}

fork.c

page3image65305088

#include <sys/time.h> #include <stdio.h> #include <errno.h>

main() {

int pid;
struct timeval start,end;
int i;
long forktime;
double avgtime;
int iters = 250;
int status; gettimeofday(&start,NULL);

#include <sys/time.h> #include <stdio.h> #include <pthread.h> #include <unistd.h> #include <stdlib.h>

void *proc();
int shared_number;

main() {

int i;
pthread_t new_thread; int sleep_time;
int seed;

shared_number = 1;

printf(“Enter a positive integer for seed: “);
scanf(“%d”,&seed);
srand48(seed); /* initialize seed of random number stream */

/* thr_create(NULL,0,proc,NULL,0,&new_thread);*/ pthread_create(&new_thread,NULL,proc,NULL);
/* create new thread */

for (i = 0; i < 50; i++) {

printf(“MAIN THREAD: i = %d, shared_number = %dn”,i,shared_number); sleep_time = 100000.0*drand48(); /* generate random sleep time */ printf(“sleep time = %d microsecondsn”,sleep_time);
usleep(sleep_time);

shared_number = shared_number + 2; }

pthread_join(new_thread,NULL);

printf(“MAIN THREAD: DONEn”); }

thr_shared.c

page4image105085200

void *proc() {

int i = 0; int DONE;

DONE = 0; while (!DONE)

{ i++;

if (i%10000 == 0)
printf(“CHILD THREAD: i = %d,shared_number = %dn”,i,shared_number);

if (i > 5000000) DONE = 1;

}
printf(“CHILD THREAD: DONEn”);

}

#include <sys/time.h> #include <stdio.h> #include <pthread.h> #include <unistd.h> #include <stdlib.h> #include <errno.h>

void *proc();
int shared_number;

main() {

int i;
pthread_t new_thread; int sleep_time;
int pid;
int status;
int seed;

shared_number = 1;

proc_shared.c

page5image105361792

printf(“Enter a positive integer for seed: “); scanf(“%d”,&seed);

srand48(seed);

if ((pid = fork()) == 0) {

proc();

exit(0); }

else if (pid == -1) {

printf(“error %dn”,errno);

exit(-1); }

else
{ /* parent process */

for (i = 0; i < 50; i++) {

/* initialize random number stream */ /* child process */

/* error */

printf(“MAIN PROCESS: i = %d, shared_number = %dn”,i,shared_number); sleep_time = 100000.0*drand48(); /* generate random sleep time */ printf(“sleep time = %d microsecondsn”,sleep_time);
usleep(sleep_time);

shared_number = shared_number + 2; }

wait(&status); /* wait for child process */

printf(“MAIN PROCESS: DONEn”); }

}

void *proc() {

int i;
int DONE;

DONE = 0;
i = 0;
while (!DONE)

{ i++;

if (i%10000 == 0)

printf(“CHILD PROCESS: i = %d,shared_number = %dn”,i,shared_number); if (i > 5000000)

DONE = 1; }

printf(“CHILD PROCESS: DONEn”); }

shared_data.c

page7image64682480

#include <sys/time.h> #include <stdio.h> #include <pthread.h> #include <unistd.h> #include <stdlib.h>

void *proc();
int shared_number;

main() {

int i;
pthread_t new_thread; int sleep_time;
int number;
int seed;

shared_number = 1;
printf(“Enter a positive integer for seed: “); scanf(“%d”,&seed);
srand48(seed);

pthread_create(&new_thread,NULL,proc,NULL);

for (i = 0; i < 20; i++) {

number = shared_number;
printf(“MAIN THREAD: i = %d, shared_number = %dn”,i,shared_number); sleep_time = 100000.0*drand48(); /* generate random sleep time */ printf(“sleep time = %d microsecondsn”,sleep_time);

usleep(sleep_time);

shared_number = number + 2; }

pthread_join(new_thread,NULL);

printf(“MAIN THREAD: DONEn”); }

void *proc() {

int number,i; int sleep_time;

printf(“CHILDn”); for (i = 0; i < 10; i++)

{
number = shared_number;
printf(“CHILD THREAD: i = %d, shared_number = %dn”,i,shared_number); sleep_time = 100000.0*drand48(); /* generate random sleep time */ printf(“sleep time = %d microsecondsn”,sleep_time);
usleep(sleep_time);
shared_number = number + 200000;

}
printf(“CHILD THREAD: DONEn”);

}

SharedData.java

import java.util.Random;
public class SharedData extends Thread {

static Random gRandom = new Random(); static int gSharedNumber = 0;
private int gID;
public SharedData(int id) {

page8image105399776

this.gID = id; }

public void run() { for(int i=0;i<20;i++) {

int number = gSharedNumber; System.out.println(“SharedData[“+gID+”](i=”+i+”) = “+gSharedNumber); try { Thread.sleep(gRandom.nextInt(1000));
} catch (InterruptedException e) { /* ignore */ }
if(gID == 0) gSharedNumber = number + 1;
else gSharedNumber = number + 1000;

} }

public static void main(String args[]) throws Exception { SharedData sd1 = new SharedData(0);
SharedData sd2 = new SharedData(1);

sd1.start(); sd2.start();

sd1.join(); sd2.join(); }

}

The Triple Bottom Line”

The concept behind the “triple bottom line” is that companies are responsible to all their stakeholders. This includes everyone who is involved with the company whether directly or indirectly, as well as the planet on which we all live. This approach sees shareholders as part of the stakeholder group, but only as part of it. Before writing your response to this week’s discussion, please review the following resource for more details on the triple bottom line: https://www.mindtools.com/pages/article/newSTR_79.htm.
How would you implement the concept of Triple Bottom Line (People, Planet, Profit) at the NAB company you created?

Sample Solution

The post The Triple Bottom Line” appeared first on homework handlers.

Psychology Forum 3 Module 3

You will complete 1 Content Presentations/Discussions throughout this course. One of the modules/weeks you will present, and for the 4 other modules/weeks you will be a part of the discussion. At the beginning of the course you will be assigned to groups of 5. If your group does not have exactly 5 members, the instructor will direct your group as to what to do.

Each group member will be assigned a module/week to record and present a brief video that includes: a summary of the reading material (12 minutes), a summary the 2 articles for that module/week (45 minutes), and 2 questions posed by the presenter. One question must deal with biblical integration and the second must pertain to why that information is important and/or how it applies in everyday life. The questions you intend to pose must be approved by the instructor before you pose them on your video submission. The video must be 1015 minutes.

For ideas on how to present, you may use your creativity and can record a narrated PowerPoint or utilize any other web-based presentation site. It would be advisable to do more than just talk for 10 minutes, as that can be very difficult to follow. Be professional, and wear professional attire for the video presentation.

For every other module/week, you will watch the video presentation posted by one of your classmates, and then answer the 2 questions that were poses at the end of the video presentation. You reply must be at least 100 words and must use at least 1 citation that is in reference to the textbook, journal articles, theory, or individual research you are doing for your paper.

The replies must look like a conversation is taking place, so the first person to respond will answer the questions as discussed above. Then, the second person will do the same, but must build off of, or at least address, the previous post before answering the questions. This will be done for the rest of the posts that follow as well.

Submit your video presentation by 11:59 p.m. (ET) on Friday of Module/Week 3. Submit your responses by 11:59 p.m. (ET) on Sunday of the same module/week.

___________

****** LINK DOWN BELOW for power point presentation
https://www.youtube.com/watch?v=8-f-LWhkTps&feature=youtu.be