I am Marianna P. I am a C Exam Expert at programmingexamhelp.com. I hold a Bachelor of Information Technology from, the California Institute of Technology, United States. I have been helping students with their exams for the past 7 years. You can hire me to take your exam in C.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the C Exam.
I am Simon M. I am a C Homework Expert at programminghomeworkhelp.com. I hold a Ph.D. in Programming, from Glasgow University, UK. I have been helping students with their homework for the past 10 years. I solve homework related to C.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.
You can also call on +1 678 648 4277 for any assistance with C Homework.
Program Assignment Process ManagementObjective This program a.docxwkyra78
Program Assignment : Process Management
Objective: This program assignment is given to the Operating Systems course to allow the students to figure out how a single process (parent process) creates a child process and how they work on Unix/Linux(/Mac OS X/Windows) environment. Additionally, student should combine the code for describing inter-process communication into this assignment. Both parent and child processes interact with each other through shared memory-based communication scheme or message passing scheme.
Environment: Unix/Linux environment (VM Linux or Triton Server, or Mac OS X), Windows platform
Language: C or C++, Java
Requirements:
i. You have wide range of choices for this assignment. First, design your program to explain the basic concept of the process management in Unix Kernel. This main idea will be evolved to show your understanding on inter-process communication, file processing, etc.
ii. Refer to the following system calls:
- fork(), getpid(), family of exec(), wait(), sleep() system calls for process management
- shmget(), shmat(), shmdt(), shmctl() for shared memory support or
- msgget(), msgsnd(), msgrcv(), msgctl(), etc. for message passing support
iii. The program should present that two different processes, both parent and child, execute as they are supposed to.
iv. The output should contain the screen capture of the execution procedure of the program.
v. Interaction between parent and child processes can be provided through inter-process communication schemes, such as shared-memory or message passing schemes.
vi. Result should be organized as a document which explains the overview of your program, code, execution results, and the conclusion including justification of your program, lessons you've learned, comments, etc.
Note:
i. In addition, please try to understand how the local and global variables work across the processes
ii. read() or write () functions are used to understand how they work on the different processes.
iii. For extra credit, you can also incorporate advanced features, like socket or thread functions, into your code.
Examples:
1. Process Creation and IPC with Shared Memory Scheme
=============================================================
#include <stdio.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
int main(){
pid_t pid;
int segment_id; //allocate the memory
char *shared_memory; //pointer to memory
const int size = 4096;
segment_id = shmget(IPC_PRIVATE, size, S_IRUSR | S_IWUSR);
shared_memory = (char *) shmat(segment_id, NULL, 0);
pid = fork();
if(pid < 0) { //error
fprintf(stderr, "Fork failed");
return 1;
}
else if(pid == 0){ //child process
char *child_shared_memory;
child_shared_memory = (char *) shmat(segment_id,NULL,0); //attach mem
sprintf(child_shared_memory, "Hello parent process!"); //write to the shared mem
shmdt(child_shared_memory);
}
else ...
Write a C++ program 1. Study the function process_text() in file.pdfjillisacebi75827
Write a C++ program
1. Study the function process_text() in file \"text_processing.cpp\". What do the string member
functions find(), substr(), c_str() do?
//text_processing.cpp
#include \"util.h\"
#include \"text_processing.h\"
#include
using namespace std;
int process_text( fstream &ifs, fstream &ofs, char target[] )
{
string replace_str( \"XXX\" ); //hard-coded string for replacement
int tlen = strlen( target ); //string length of target
int max_len = 200; //maximum length of a line
char s[max_len+1];
clear_screen(); //clear the screen
while ( !ifs.eof() ) {
int i2, i1 = 0, len=0;
ifs.getline( s, max_len ); //get one line from file
string str( s ); //construct a string object
i2 = str.find ( target, i1 ); //find target
len = i2 - i1;
if ( i2 > -1 && len > 0 ){ //if target found
print_text( str.substr( i1, i2 ).c_str() ); //print up to target
ofs << str.substr( i1, i2 );
}
while ( i2 > -1 ) {
print_text_inverse ( target ); //highlight target
ofs << replace_str;
i1 = i2 + tlen; //new search position
i2 = str.find ( target, i1 ); //find next target
len = i2 - i1;
if ( i2 > -1 && len > 0 ){ //found target
print_text( str.substr( i1, len ).c_str() ); //print up to target
ofs << str.substr( i1, len );
}
}
len = str.length() - i1;
if ( len > 0 ) { //print the remainder
print_text( str.substr( i1, len ).c_str() );
ofs << str.substr( i1, len );
}
ofs << endl;
getnstr( s, 1 ); //prompt for
} //while ( !ifs.eof() )
restore_screen(); //restore the old screen
return 1;
}
//text_processing.h
#ifndef TEXT_PROCESSING_H
#define TEXT_PROCESSING_H
#include
#include
using namespace std;
int process_text( fstream &ifs, fstream &ofs, char target[] );
#endif
//util.h
#ifndef UTIL_H
#define UTIL_H
#include
#include
#include
#include
#include
using namespace std;
void usage ( char program_name[] );
void clear_screen();
void print_text( const char *s );
void print_text_inverse( const char *s );
void get_input_text( char *s, int max_len );
void restore_screen();
#endif
//util.cpp
#include \"util.h\"
void usage ( char program_name[] )
{
cout << \"Usage: \" << program_name << \" infile outfile search_string\" << endl;
return;
}
/*
The following are some curses functions. You can find
the details by the command \"man ncurses\". But its use
can be transparent to you.
*/
void clear_screen()
{
initscr();
scrollok ( stdscr, true ); //allow window to scroll
}
void print_text ( const char *s )
{
printw(\"%s\", s );
refresh();
}
void print_text_inverse( const char *s )
{
attron( A_REVERSE );
printw(\"%s\", s );
attroff( A_REVERSE );
refresh();
}
void get_input_text( char *s, int max_len )
{
getnstr( s, max_len );
}
void restore_screen()
{
endwin();
}
//str_main.cpp
#include \"util.h\"
#include \"text_processing.h\"
#include
using namespace std;
/*
Note that grace_open() must be defined in same file
as main(), otherwise the destructor of fstream will
automatically close the opened file as it finds that
its out of scope upon exiting the function.
*/
int grace_open( char *s, fst.
The ProblemUsing C programming language write a program that simul.pdffederaleyecare
The Problem
Using C programming language write a program that simulates the Tiny Machine Architecture.
Your code must implement the basic instruction set that the Tiny Machine Architecture adheres
to (LOAD[1], ADD[2], STORE[3], SUB[4], IN[5], OUT[6], END[7], JMP[8], SKIPZ[9]). Each
piece of the architecture must be accurately represented in your code (Instruction Register,
Program Counter, Memory Address Register, Data Memory, Memory Data Register, and
Accumulator). Data Memory will be represented by a 0-9 array. Your Program Counter will
begin at 10.
For the sake of simplicity Program Memory and Data Memory may be implemented as separate
arrays.
Hint: Implementing a struct for your Instructions and an array of these structs as your Program
Memory greatly simplifies this program.
Example:
typedef struct {
int opCode, deviceOrAddress;
} Instruction;
Instruction programMemory[MAXPROGRAMSIZE];
Input Specifications
Your simulator must run from the command line with a single input file as a parameter to main.
This file will contain a sequence of instructions for your simulator to assemble (store in
“program memory”) and then run via the fetch/execute cycle.
Example:
5 5 //IN 5
6 7 //OUT 7
3 0 //STORE 0
5 5 //IN 5
6 7 //OUT 7
3 1 //STORE 1
1 0 //LOAD 0
4 1 //SUB 1
3 0 //STORE 0
6 7 //OUT 7
1 1 //LOAD 1
6 7 //OUT 7
7 0 //END
Output Specifications
Your simulator should provide output according to the input file. Along with this output your
program should provide status messages identifying details on the workings of your simulator.
Output text does not have to reflect my example word-for-word, but please provide detail on the
program as it runs in a readable format that does not conflict with the actual output of your
simulator. After each instruction print the current state of the Program Counter, Accumulator,
and Data Memory. The INPUT instruction is the only one that should prompt an interaction from
the user.
Example:
Assembling Program…
Program Assembled.
Run.
PC = 10 | A = NULL | MEM = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
/* input value */
X
PC = 11 | A = X | MEM = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
/* outputting accumulator to screen */
X
PC = 12 | A = X | MEM = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
/* storing accumulator to memory location 0 */
PC = 13 | A = X | MEM = [X, 0, 0, 0, 0, 0, 0, 0, 0, 0]
… etc
Program complete.
Grading
Your simulator will be graded on the above criteria. Your program should compile and run from
the command line with one input file parameter. Please note that your program will not just be
graded on whether or not it runs successfully; accurate simulation and a thorough demonstration
of your understanding on the workings of this architecture will constitute a large portion of this
grade. As that is the case it is in your best interest to comment your program in a concise and
readable way. However, if your program does not run or compile the maximum points possible
will be 50 (up to 25 may be recovered by debugging and demonstrating a.
I am Joseph G . I am a Programming Assignment Expert at programminghomeworkhelp.com. I hold a Ph.D. Programming, Schiller International University, USA. I have been helping students with their homework for the past 8 years. I solve assignments related to Programming.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.
You can also call on +1 678 648 4277 for any assistance with Programming Assignments.
I am Simon M. I am a C Homework Expert at programminghomeworkhelp.com. I hold a Ph.D. in Programming, from Glasgow University, UK. I have been helping students with their homework for the past 10 years. I solve homework related to C.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.
You can also call on +1 678 648 4277 for any assistance with C Homework.
Program Assignment Process ManagementObjective This program a.docxwkyra78
Program Assignment : Process Management
Objective: This program assignment is given to the Operating Systems course to allow the students to figure out how a single process (parent process) creates a child process and how they work on Unix/Linux(/Mac OS X/Windows) environment. Additionally, student should combine the code for describing inter-process communication into this assignment. Both parent and child processes interact with each other through shared memory-based communication scheme or message passing scheme.
Environment: Unix/Linux environment (VM Linux or Triton Server, or Mac OS X), Windows platform
Language: C or C++, Java
Requirements:
i. You have wide range of choices for this assignment. First, design your program to explain the basic concept of the process management in Unix Kernel. This main idea will be evolved to show your understanding on inter-process communication, file processing, etc.
ii. Refer to the following system calls:
- fork(), getpid(), family of exec(), wait(), sleep() system calls for process management
- shmget(), shmat(), shmdt(), shmctl() for shared memory support or
- msgget(), msgsnd(), msgrcv(), msgctl(), etc. for message passing support
iii. The program should present that two different processes, both parent and child, execute as they are supposed to.
iv. The output should contain the screen capture of the execution procedure of the program.
v. Interaction between parent and child processes can be provided through inter-process communication schemes, such as shared-memory or message passing schemes.
vi. Result should be organized as a document which explains the overview of your program, code, execution results, and the conclusion including justification of your program, lessons you've learned, comments, etc.
Note:
i. In addition, please try to understand how the local and global variables work across the processes
ii. read() or write () functions are used to understand how they work on the different processes.
iii. For extra credit, you can also incorporate advanced features, like socket or thread functions, into your code.
Examples:
1. Process Creation and IPC with Shared Memory Scheme
=============================================================
#include <stdio.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
int main(){
pid_t pid;
int segment_id; //allocate the memory
char *shared_memory; //pointer to memory
const int size = 4096;
segment_id = shmget(IPC_PRIVATE, size, S_IRUSR | S_IWUSR);
shared_memory = (char *) shmat(segment_id, NULL, 0);
pid = fork();
if(pid < 0) { //error
fprintf(stderr, "Fork failed");
return 1;
}
else if(pid == 0){ //child process
char *child_shared_memory;
child_shared_memory = (char *) shmat(segment_id,NULL,0); //attach mem
sprintf(child_shared_memory, "Hello parent process!"); //write to the shared mem
shmdt(child_shared_memory);
}
else ...
Write a C++ program 1. Study the function process_text() in file.pdfjillisacebi75827
Write a C++ program
1. Study the function process_text() in file \"text_processing.cpp\". What do the string member
functions find(), substr(), c_str() do?
//text_processing.cpp
#include \"util.h\"
#include \"text_processing.h\"
#include
using namespace std;
int process_text( fstream &ifs, fstream &ofs, char target[] )
{
string replace_str( \"XXX\" ); //hard-coded string for replacement
int tlen = strlen( target ); //string length of target
int max_len = 200; //maximum length of a line
char s[max_len+1];
clear_screen(); //clear the screen
while ( !ifs.eof() ) {
int i2, i1 = 0, len=0;
ifs.getline( s, max_len ); //get one line from file
string str( s ); //construct a string object
i2 = str.find ( target, i1 ); //find target
len = i2 - i1;
if ( i2 > -1 && len > 0 ){ //if target found
print_text( str.substr( i1, i2 ).c_str() ); //print up to target
ofs << str.substr( i1, i2 );
}
while ( i2 > -1 ) {
print_text_inverse ( target ); //highlight target
ofs << replace_str;
i1 = i2 + tlen; //new search position
i2 = str.find ( target, i1 ); //find next target
len = i2 - i1;
if ( i2 > -1 && len > 0 ){ //found target
print_text( str.substr( i1, len ).c_str() ); //print up to target
ofs << str.substr( i1, len );
}
}
len = str.length() - i1;
if ( len > 0 ) { //print the remainder
print_text( str.substr( i1, len ).c_str() );
ofs << str.substr( i1, len );
}
ofs << endl;
getnstr( s, 1 ); //prompt for
} //while ( !ifs.eof() )
restore_screen(); //restore the old screen
return 1;
}
//text_processing.h
#ifndef TEXT_PROCESSING_H
#define TEXT_PROCESSING_H
#include
#include
using namespace std;
int process_text( fstream &ifs, fstream &ofs, char target[] );
#endif
//util.h
#ifndef UTIL_H
#define UTIL_H
#include
#include
#include
#include
#include
using namespace std;
void usage ( char program_name[] );
void clear_screen();
void print_text( const char *s );
void print_text_inverse( const char *s );
void get_input_text( char *s, int max_len );
void restore_screen();
#endif
//util.cpp
#include \"util.h\"
void usage ( char program_name[] )
{
cout << \"Usage: \" << program_name << \" infile outfile search_string\" << endl;
return;
}
/*
The following are some curses functions. You can find
the details by the command \"man ncurses\". But its use
can be transparent to you.
*/
void clear_screen()
{
initscr();
scrollok ( stdscr, true ); //allow window to scroll
}
void print_text ( const char *s )
{
printw(\"%s\", s );
refresh();
}
void print_text_inverse( const char *s )
{
attron( A_REVERSE );
printw(\"%s\", s );
attroff( A_REVERSE );
refresh();
}
void get_input_text( char *s, int max_len )
{
getnstr( s, max_len );
}
void restore_screen()
{
endwin();
}
//str_main.cpp
#include \"util.h\"
#include \"text_processing.h\"
#include
using namespace std;
/*
Note that grace_open() must be defined in same file
as main(), otherwise the destructor of fstream will
automatically close the opened file as it finds that
its out of scope upon exiting the function.
*/
int grace_open( char *s, fst.
The ProblemUsing C programming language write a program that simul.pdffederaleyecare
The Problem
Using C programming language write a program that simulates the Tiny Machine Architecture.
Your code must implement the basic instruction set that the Tiny Machine Architecture adheres
to (LOAD[1], ADD[2], STORE[3], SUB[4], IN[5], OUT[6], END[7], JMP[8], SKIPZ[9]). Each
piece of the architecture must be accurately represented in your code (Instruction Register,
Program Counter, Memory Address Register, Data Memory, Memory Data Register, and
Accumulator). Data Memory will be represented by a 0-9 array. Your Program Counter will
begin at 10.
For the sake of simplicity Program Memory and Data Memory may be implemented as separate
arrays.
Hint: Implementing a struct for your Instructions and an array of these structs as your Program
Memory greatly simplifies this program.
Example:
typedef struct {
int opCode, deviceOrAddress;
} Instruction;
Instruction programMemory[MAXPROGRAMSIZE];
Input Specifications
Your simulator must run from the command line with a single input file as a parameter to main.
This file will contain a sequence of instructions for your simulator to assemble (store in
“program memory”) and then run via the fetch/execute cycle.
Example:
5 5 //IN 5
6 7 //OUT 7
3 0 //STORE 0
5 5 //IN 5
6 7 //OUT 7
3 1 //STORE 1
1 0 //LOAD 0
4 1 //SUB 1
3 0 //STORE 0
6 7 //OUT 7
1 1 //LOAD 1
6 7 //OUT 7
7 0 //END
Output Specifications
Your simulator should provide output according to the input file. Along with this output your
program should provide status messages identifying details on the workings of your simulator.
Output text does not have to reflect my example word-for-word, but please provide detail on the
program as it runs in a readable format that does not conflict with the actual output of your
simulator. After each instruction print the current state of the Program Counter, Accumulator,
and Data Memory. The INPUT instruction is the only one that should prompt an interaction from
the user.
Example:
Assembling Program…
Program Assembled.
Run.
PC = 10 | A = NULL | MEM = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
/* input value */
X
PC = 11 | A = X | MEM = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
/* outputting accumulator to screen */
X
PC = 12 | A = X | MEM = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
/* storing accumulator to memory location 0 */
PC = 13 | A = X | MEM = [X, 0, 0, 0, 0, 0, 0, 0, 0, 0]
… etc
Program complete.
Grading
Your simulator will be graded on the above criteria. Your program should compile and run from
the command line with one input file parameter. Please note that your program will not just be
graded on whether or not it runs successfully; accurate simulation and a thorough demonstration
of your understanding on the workings of this architecture will constitute a large portion of this
grade. As that is the case it is in your best interest to comment your program in a concise and
readable way. However, if your program does not run or compile the maximum points possible
will be 50 (up to 25 may be recovered by debugging and demonstrating a.
I am Joseph G . I am a Programming Assignment Expert at programminghomeworkhelp.com. I hold a Ph.D. Programming, Schiller International University, USA. I have been helping students with their homework for the past 8 years. I solve assignments related to Programming.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.
You can also call on +1 678 648 4277 for any assistance with Programming Assignments.
Lab01Files/build.bat
@echo off
cls
set DRIVE_LETTER=%1:
set PATH=%DRIVE_LETTER%\MinGW\bin;%DRIVE_LETTER%\MinGW\msys\1.0\bin;c:\Windows;c:\Windows\system32
g++ -c Keyboard.cpp
g++ -c Random.cpp
g++ -c String.cpp
g++ -c ReadFile.cpp
g++ -c WriteFile.cpp
g++ -c PlayerGuessDriver.cpp
g++ -o PlayerGuess.exe PlayerGuessDriver.o ReadFile.o WriteFile.o String.o Keyboard.o Random.o
Lab01Files/Keyboard.cpp
#include "Keyboard.h"
#include <iostream>
int readInt(string prompt)
{
cout << prompt;
int val = 0;
cin >> val;
return val;
}
int getValidatedInt(string prompt, int min, int max)
{
int validated = readInt(prompt);
cout << validated << endl;
while(validated < min || validated > max)
{
validated = readInt(prompt);
cout << validated << endl;
}
return validated;
}
double readDouble(string prompt)
{
cout << prompt;
double val = 0;
cin >> val;
return val;
}
double getValidatedDouble(string prompt, double min, double max)
{
double validated = readDouble(prompt);
cout << validated << endl;
while(validated < min || validated > max)
{
validated = readDouble(prompt);
cout << validated << endl;
}
return validated;
}
String* readString(string prompt)
{
cout << prompt;
string text;
getline(cin, text);
String* str = createString(text.c_str());
return str;
}
Lab01Files/Keyboard.h
#if !defined KEYBOARD
#define KEYBOARD
#include "Text.h"
#include <string>
using namespace std;
//pre: the string (character literal) that will prompt the user for input
//post: the input read from the keyboard interpreted as an int is returned
int readInt(string prompt);
int getValidatedInt(string prompt, int min, int max);
//pre: the string that will prompt the user for input
//post: the input read from the keyboard interpreted as a double is returned
double readDouble(string prompt);
double getValidatedDouble(string prompt, double min, double max);
//pre: the string that will prompt the user for input
// the string to store the user input and the length of the input storage string
//post: the text read from the keyboard is copied into the storage string
String* readString(string prompt);
#endif
Lab01Files/Laboratory 01_ Guessing Game.pdf
8/28/2014 Laboratory 01: Guessing Game
http://mboshart.dyndns.org/boshart/2111Labs/Lab01.html 1/3
Laboratory 01: Guessing Game
Download the following files and place them in your working directory:
Starting code for this lab:
Lab01Files.zip //provided, completed files, refer to header files for method
signatures
PlayerGuessDriver.cpp //most of the work is in this file
range.txt //contains the two integers that define the range for the secret
number
build.bat //convenience file for compiling and linking
Guessing Game
In this lab, you will write a simple guessing game. The computer will generate a
random integer within a valid spe ...
httplinux.die.netman3execfork() creates a new process by.docxadampcarr67227
http://linux.die.net/man/3/exec
fork() creates a new process by duplicating the calling process. The new process, referred to as the child, is an exact duplicate of the calling process, referred to as the parent#include <unistd.h>pid_t fork(void);
The exec() family of functions replaces the current process image with a new process image. The functions described in this manual page are front-ends for execve(2). (See the manual page for execve(2) for further details about the replacement of the current process image.)
The exec() family of functions include execl, execlp, execle, execv, execvp, and execvpe to execute a file.
The ANSI prototype for execl() is:
int execl(const char *path, const char *arg0,..., const char *argn, 0)
http://www.cems.uwe.ac.uk/~irjohnso/coursenotes/lrc/system/pc/pc4.htm #inciude <stdio.h> #inciude <unistd.h> main() { execl("/bin/ls", "ls", "-l", 0); printf("Can only get here on error\n"); }
The first parameter to execl() in this example is the full pathname to the ls command. This is the file whose contents will be run, provided the process has execute permission on the file. The rest of the execl() parameters provide the strings to which the argv array elements in the new program will point. In this example, it means that the ls program will see the string ls pointed to by its argv[0], and the string -l pointed to by itsargv[1]. In addition to making all these parameters available to the new program, the exec() calls also pass a value for the variable: extern char **environ;
This variable has the same format as the argv variable except that the items passed via environ are the values in the environment of the process (like any exported shell variables), rather than the command line parameters. In the case of execl(), the value of the environ variable in the new program will be a copy of the value of this variable in the calling process.
The execl() version of exec() is fine in the circumstances where you can ex-plicitly list all of the parameters, as in the previous example. Now suppose you want to write a program that doesn't just run ls, but will run any program you wish, and pass it any number of appropriate command line parameters. Obviously, execl() won't do the job.
The example program below, which implements this requirement, shows, however, that the system call execv() will perform as required: #inciude <stdio.h> main(int argc, char **argv) { if (argc==1) { printf("Usage: run <command> [<paraneters>]\n"); exit(1) } execv(argv[l], &argv[1)); printf("Sorry... couldn't run that!\n"); }
The prototype for execv() shows that it only takes two parameters, the first is the full pathname to the command to execute and the second is the argv value you want to pass into the new program. In the previous example this value was derived from the argv value passed into the run command, so that the run command can take the command line parameter values you pass it and just pass them on. int execl(.
Hello. I was wondering if I could get some help on this C programmin.pdffashionfootwear1
find the area of the sector of a circle of radius 16 units subtended by an angle of 300 degrees
find the area of the sector of a circle of radius 16 units subtended by an angle of 300 degrees
find the area of the sector of a circle of radius 16 units subtended by an angle of 300 degrees
Solution
given radius r=16 ,=300o
area of sector=(/180o)(/2)r2
area of sector=(300o/180o)*(/2)*162
area of sector=(5/3)*(/2)*256
area of sector=640/3 squareunits
area of sector=670.2 squareunits.
Article link httpiveybusinessjournal.compublicationmanaging-.docxfredharris32
Article link: http://iveybusinessjournal.com/publication/managing-global-risk-to-seize-competitive-advantage/
Requirements: Write one summary and study note both no longer than one pages should include all point of article. Then do a PPT and write a presenting paper only for 5 minutes.
Groups of students will create and offer two MS PowerPoint presentation summarizing the main points of one of the readings for this course along with a one page handout for the students in the class. The aim of the presentations and the handouts is to provide the audience with the main ideas of the article and study notes. Groups will bring to class enough copies of the handout for each student in the class. The handout should list the name of the author, the title of the article, the title of the journal, and the publication date and page numbers along with a summary of its main points. Please do not exceed one page for this material.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* Read a .dat file and reverse it.
*/
public class Reverse {
public static void main(String[]args) {
if (args.length != 3) {
System.err.println(" Incorrect number of arguments");
System.err.println(" Usage: ");
System.err.
println("\tjava Reverse <stack type> <input file> <output file>");
System.exit(1);
}
boolean useList = true;
if (args[0].compareTo("list")==0)
useList = true;
else if (args[0].compareTo("array")==0)
useList = false;
else {
System.err.println("\tSaw "+args[0]+" instead of list or array as first argument");
System.exit(1);
}
try {
//
// Set up the input file to read, and the output file to write to
//
BufferedReader fileIn =
new BufferedReader(new FileReader(args[1]));
PrintWriter fileOut =
new PrintWriter(new
BufferedWriter(new FileWriter(args[2])));
//
// Read the first line of the .dat file to get sample rate.
// We want to store the sample rate value in a variable,
// but we can ignore the "; Sample Rate" part of the line.
// Step through the first line one token (word) at a time
// using the StringTokenizer. The fourth token is the one
// we want (the sample rate).
//
StringTokenizer str;
String oneLine;
int sampleRate;
String strJunk;
oneLine = fileIn.readLine();
str = new StringTokenizer(oneLine);
strJunk = str.nextToken(); // Read in semicolon
strJunk = str.nextToken(); // Read in "Sample"
strJunk = str.nextToken(); // Read in "Rate"
// ...
My name is Joanna R. I have been associated with programmingexam.com for the past 14 years and have been assisting the programming students with their Algorithm Design Exams. I have a Business Analysis of Information Technology, Montreal College of Information Technology, Canada.
I am Marianna P. Currently associated with programmingexamhelp.com as an Algorithms Exam Expert. After completing my PhD. in Programming, from Curtin University, Australia, I was in search of an opportunity that expands my area of knowledge hence I decided to help students with their assignments. I have written various programming exams till date to help students overcome numerous difficulties they face.
Lab01Files/build.bat
@echo off
cls
set DRIVE_LETTER=%1:
set PATH=%DRIVE_LETTER%\MinGW\bin;%DRIVE_LETTER%\MinGW\msys\1.0\bin;c:\Windows;c:\Windows\system32
g++ -c Keyboard.cpp
g++ -c Random.cpp
g++ -c String.cpp
g++ -c ReadFile.cpp
g++ -c WriteFile.cpp
g++ -c PlayerGuessDriver.cpp
g++ -o PlayerGuess.exe PlayerGuessDriver.o ReadFile.o WriteFile.o String.o Keyboard.o Random.o
Lab01Files/Keyboard.cpp
#include "Keyboard.h"
#include <iostream>
int readInt(string prompt)
{
cout << prompt;
int val = 0;
cin >> val;
return val;
}
int getValidatedInt(string prompt, int min, int max)
{
int validated = readInt(prompt);
cout << validated << endl;
while(validated < min || validated > max)
{
validated = readInt(prompt);
cout << validated << endl;
}
return validated;
}
double readDouble(string prompt)
{
cout << prompt;
double val = 0;
cin >> val;
return val;
}
double getValidatedDouble(string prompt, double min, double max)
{
double validated = readDouble(prompt);
cout << validated << endl;
while(validated < min || validated > max)
{
validated = readDouble(prompt);
cout << validated << endl;
}
return validated;
}
String* readString(string prompt)
{
cout << prompt;
string text;
getline(cin, text);
String* str = createString(text.c_str());
return str;
}
Lab01Files/Keyboard.h
#if !defined KEYBOARD
#define KEYBOARD
#include "Text.h"
#include <string>
using namespace std;
//pre: the string (character literal) that will prompt the user for input
//post: the input read from the keyboard interpreted as an int is returned
int readInt(string prompt);
int getValidatedInt(string prompt, int min, int max);
//pre: the string that will prompt the user for input
//post: the input read from the keyboard interpreted as a double is returned
double readDouble(string prompt);
double getValidatedDouble(string prompt, double min, double max);
//pre: the string that will prompt the user for input
// the string to store the user input and the length of the input storage string
//post: the text read from the keyboard is copied into the storage string
String* readString(string prompt);
#endif
Lab01Files/Laboratory 01_ Guessing Game.pdf
8/28/2014 Laboratory 01: Guessing Game
http://mboshart.dyndns.org/boshart/2111Labs/Lab01.html 1/3
Laboratory 01: Guessing Game
Download the following files and place them in your working directory:
Starting code for this lab:
Lab01Files.zip //provided, completed files, refer to header files for method
signatures
PlayerGuessDriver.cpp //most of the work is in this file
range.txt //contains the two integers that define the range for the secret
number
build.bat //convenience file for compiling and linking
Guessing Game
In this lab, you will write a simple guessing game. The computer will generate a
random integer within a valid spe ...
httplinux.die.netman3execfork() creates a new process by.docxadampcarr67227
http://linux.die.net/man/3/exec
fork() creates a new process by duplicating the calling process. The new process, referred to as the child, is an exact duplicate of the calling process, referred to as the parent#include <unistd.h>pid_t fork(void);
The exec() family of functions replaces the current process image with a new process image. The functions described in this manual page are front-ends for execve(2). (See the manual page for execve(2) for further details about the replacement of the current process image.)
The exec() family of functions include execl, execlp, execle, execv, execvp, and execvpe to execute a file.
The ANSI prototype for execl() is:
int execl(const char *path, const char *arg0,..., const char *argn, 0)
http://www.cems.uwe.ac.uk/~irjohnso/coursenotes/lrc/system/pc/pc4.htm #inciude <stdio.h> #inciude <unistd.h> main() { execl("/bin/ls", "ls", "-l", 0); printf("Can only get here on error\n"); }
The first parameter to execl() in this example is the full pathname to the ls command. This is the file whose contents will be run, provided the process has execute permission on the file. The rest of the execl() parameters provide the strings to which the argv array elements in the new program will point. In this example, it means that the ls program will see the string ls pointed to by its argv[0], and the string -l pointed to by itsargv[1]. In addition to making all these parameters available to the new program, the exec() calls also pass a value for the variable: extern char **environ;
This variable has the same format as the argv variable except that the items passed via environ are the values in the environment of the process (like any exported shell variables), rather than the command line parameters. In the case of execl(), the value of the environ variable in the new program will be a copy of the value of this variable in the calling process.
The execl() version of exec() is fine in the circumstances where you can ex-plicitly list all of the parameters, as in the previous example. Now suppose you want to write a program that doesn't just run ls, but will run any program you wish, and pass it any number of appropriate command line parameters. Obviously, execl() won't do the job.
The example program below, which implements this requirement, shows, however, that the system call execv() will perform as required: #inciude <stdio.h> main(int argc, char **argv) { if (argc==1) { printf("Usage: run <command> [<paraneters>]\n"); exit(1) } execv(argv[l], &argv[1)); printf("Sorry... couldn't run that!\n"); }
The prototype for execv() shows that it only takes two parameters, the first is the full pathname to the command to execute and the second is the argv value you want to pass into the new program. In the previous example this value was derived from the argv value passed into the run command, so that the run command can take the command line parameter values you pass it and just pass them on. int execl(.
Hello. I was wondering if I could get some help on this C programmin.pdffashionfootwear1
find the area of the sector of a circle of radius 16 units subtended by an angle of 300 degrees
find the area of the sector of a circle of radius 16 units subtended by an angle of 300 degrees
find the area of the sector of a circle of radius 16 units subtended by an angle of 300 degrees
Solution
given radius r=16 ,=300o
area of sector=(/180o)(/2)r2
area of sector=(300o/180o)*(/2)*162
area of sector=(5/3)*(/2)*256
area of sector=640/3 squareunits
area of sector=670.2 squareunits.
Article link httpiveybusinessjournal.compublicationmanaging-.docxfredharris32
Article link: http://iveybusinessjournal.com/publication/managing-global-risk-to-seize-competitive-advantage/
Requirements: Write one summary and study note both no longer than one pages should include all point of article. Then do a PPT and write a presenting paper only for 5 minutes.
Groups of students will create and offer two MS PowerPoint presentation summarizing the main points of one of the readings for this course along with a one page handout for the students in the class. The aim of the presentations and the handouts is to provide the audience with the main ideas of the article and study notes. Groups will bring to class enough copies of the handout for each student in the class. The handout should list the name of the author, the title of the article, the title of the journal, and the publication date and page numbers along with a summary of its main points. Please do not exceed one page for this material.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* Read a .dat file and reverse it.
*/
public class Reverse {
public static void main(String[]args) {
if (args.length != 3) {
System.err.println(" Incorrect number of arguments");
System.err.println(" Usage: ");
System.err.
println("\tjava Reverse <stack type> <input file> <output file>");
System.exit(1);
}
boolean useList = true;
if (args[0].compareTo("list")==0)
useList = true;
else if (args[0].compareTo("array")==0)
useList = false;
else {
System.err.println("\tSaw "+args[0]+" instead of list or array as first argument");
System.exit(1);
}
try {
//
// Set up the input file to read, and the output file to write to
//
BufferedReader fileIn =
new BufferedReader(new FileReader(args[1]));
PrintWriter fileOut =
new PrintWriter(new
BufferedWriter(new FileWriter(args[2])));
//
// Read the first line of the .dat file to get sample rate.
// We want to store the sample rate value in a variable,
// but we can ignore the "; Sample Rate" part of the line.
// Step through the first line one token (word) at a time
// using the StringTokenizer. The fourth token is the one
// we want (the sample rate).
//
StringTokenizer str;
String oneLine;
int sampleRate;
String strJunk;
oneLine = fileIn.readLine();
str = new StringTokenizer(oneLine);
strJunk = str.nextToken(); // Read in semicolon
strJunk = str.nextToken(); // Read in "Sample"
strJunk = str.nextToken(); // Read in "Rate"
// ...
My name is Joanna R. I have been associated with programmingexam.com for the past 14 years and have been assisting the programming students with their Algorithm Design Exams. I have a Business Analysis of Information Technology, Montreal College of Information Technology, Canada.
I am Marianna P. Currently associated with programmingexamhelp.com as an Algorithms Exam Expert. After completing my PhD. in Programming, from Curtin University, Australia, I was in search of an opportunity that expands my area of knowledge hence I decided to help students with their assignments. I have written various programming exams till date to help students overcome numerous difficulties they face.
I am Gabriel C. I love exploring new topics. Academic writing seemed an interesting option for me. After working for many years with programmingexamhelp.com, I have assisted many students with their exams. I can proudly say, each student I have served is happy with the quality of the solution that I have provided. I have acquired Business analyst of Information Technology, Montreal College of Information Technology, Canada.
My name is Justin M. I have been associated with programmingexam.com for the past 10 years and have been assisting the programming students with their Algorithm Exam.
I have a Bachelor of software engineering, from the University of Massachusetts Amherst, United States.
I am Charles B. I am an Algorithm Exam Expert at programmingexamhelp.com. I hold a Ph.D. in Programming from Texas University, USA. I have been helping students with their exams for the past 15 years. You can hire me to take your exam in Algorithm.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Exam.
I am Marianna P. I am an Algorithm Exam Expert at programmingexamhelp.com. I hold a PhD. in Programming, from Curtin University, Australia. I have been helping students with their exams for the past 12 years. You can hire me to take your exam in Algorithm.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Exam.
I am Dennis L. I am an Algorithm Design Exam Expert at programmingexamhelp.com. I hold a Ph.D. in Computer Science from, the City University of New York. I have been helping students with their exams for the past 7 years. You can hire me to take your exam in Algorithm Design.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Design Exam.
I am Blake H. I am an Algorithm Exam Expert at programmingexamhelp.com. I hold a PhD. in Programming, from Curtin University, Australia. I have been helping students with their exams for the past 10 years. You can hire me to take your exam in Algorithm.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Exam.
I am Justin M. I am an Algorithm Design Exam Expert at programmingexamhelp.com. I hold a Bachelor of software engineering from, the University of Massachusetts Amherst, United States. I have been helping students with their exams for the past 9 years. You can hire me to take your exam in Algorithm Design.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Design Exam.
I am Justin M. I am an Algorithm Exam Expert at programmingexamhelp.com. I hold a Bachelor of software engineering from, the University of Massachusetts Amherst, United States. I have been helping students with their exams for the past 9 years. You can hire me to take your exam in Algorithm.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Exam.
I am Joanna R. I am an Algorithm Exam Expert at programmingexamhelp.com. I hold a Bachelor of Information Technology from, the California Institute of Technology, United States. I have been helping students with their exams for the past 9 years. You can hire me to take your exam in Algorithm.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Exam.
I am Gabriel C. I am an Algorithm Exam Expert at programmingexamhelp.com. I am a Business analyst of Information Technology, Montreal College of Information Technology, Canada. I have been helping students with their exams for the past 8 years. You can hire me to take your exam in Algorithm.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Exam.
I am Justin M. I am an Algorithm Exam Expert at programmingexamhelp.com. I hold a Bachelor of software engineering, the University of Massachusetts Amherst, United States. I have been helping students with their exams for the past 10 years. You can hire me to take your exam in Algorithm.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Exam.
I am Gabriel C. I am a C Exam Expert at programmingexamhelp.com. I hold a PhD. in Business analyst of Information Technology, Montreal College of Information Technology, Canada. I have been helping students with their exams for the past 8 years. You can hire me to take your exam in C.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the C Exam.
I am Gabriel C. I am a Computer Science Exam Expert at programmingexamhelp.com. I hold a Business analyst of Information Technology, Montreal College of Information Technology, Canada. I have been helping students with their exams for the past 11 years. You can hire me to take your exam in Computer Science.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Computer Science Exam.
I am Charles B. I am a Programming Exam Expert at programmingexamhelp.com. I hold a Ph.D. in Programming Texas University, USA. I have been helping students with their exams for the past 9 years. You can hire me to take your exam in Programming.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Programming Exam.
I am Marianna P. I am an Algorithm Exam Expert at programmingexamhelp.com. I hold a PhD. in Programming, from Curtin University, Australia. I have been helping students with their exams for the past 10 years. You can hire me to take your exam in Algorithm.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Exam.
I am Dennis L. I am a Programming Exam Expert at programmingexamhelp.com. I hold a Ph.D. in Computer Science from, City University of New York. I have been helping students with their exams for the past 9 years. You can hire me to take your exam in Programming.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Programming Exam.
I am Justin M. I am a Programming Exam Expert at programmingexamhelp.com. I hold a Bachelor of software engineering from, the University of Massachusetts Amherst, United States. I have been helping students with their exams for the past 9 years. You can hire me to take your exam in Programming.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Programming Exam.
I am Blake H. I am an Algorithm Exam Expert at programmingexamhelp.com. I hold a PhD. in Programming, from Curtin University, Australia. I have been helping students with their exams for the past 10 years. You can hire me to take your exam in Algorithm.
Visit programmingexamhelp.com or email support@programmingexamhelp.com. You can also call on +1 678 648 4277 for any assistance with the Algorithm Exam.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
1. For any Programming Exam related queries, Call us at : - +1 678 648 4277
You can mail us at : - support@programmingexamhelp.com or
reach us at : - https://www.programmingexamhelp.com
2. Simulation of ARM Processor and Stack Operation
Your task for this lab is to write a program that extends the simulation of the ARM
processor and includes stack operations.
The program will have an array that represents the general ARM registers, and a second
multi-dimensional array that represents memory. The program must also have allocated
stack space within the memory array.
The program will read content into the memory array from a file, execute the
instructions it finds in the array one instruction at a time, and print the contents of the
registers (including a program counter) and stack after each instruction. Note, when
printing the stack do not print anything below the stack pointer, or above your stack
base.
The program will implement the following instructions: ADD, ADDI, SUBI, LDUR,
STUR, B, BL, BR. And at least on Conditional Branch instruction.
Instructions in memory will use the assembly mnemonics rather than binary op codes.
Instruction arguments will be register aliases (ex. X0, X1, X2, …) memory locations in
the memory array (100, 104, …), or immediate values (#-3, #5, #0, …).
The program should use the specific address - 200, as the default address for the
start instructions in memory.
programmingexamhelp.com
3. Load and store instructions will only use indirect addressing (ie. [Xn, #nn] ).
Branch instructions will use immediate or register addressing.
The program can limit the number of registers available for use in the program. At least 8
must be available, including X0, X1, X9, X10, SP (X28), LR (X30). Additional registers
may be implemented.
Data will be signed integers.
The Stack:
The stack must be at least 100 words deep. Make sure your stack will not
grow over your program/data area.
The program must have a check and a “Ran out of Stack Space/Stack
Overflow” error message.
Choose a high memory area for the stack.
The stack should grow down.
Stack memory locations should be on double word boundaries
(increment/decrement by 8).
Remember to initiate the stack pointer (SP) to the top of the stack.
Use BR XZR to halt the program.
Test Files:
programmingexamhelp.com
4. Students will create an input file to test their emulator. The program must be able
to read the name of the file as an argument
The instructions in the file to be executed must include:
At least one example of each instruction implemented.
At least 12 instructions.
Instructions to complete at least one loop.
At least one push and pop on the stack.
At least one function call.
Output
The output of the program will be a listing showing:
The current instruction
The values of any registers used in that instruction. Including the
Program Counter.
The portion of the stack which is in use – (note: this may be limited to
the current stack frame).
Additional information, such as the value of all registers, or other useful
items may be shown as well.
SAMPLE OUTPUT
Instruction executed: LDUR X0, XZR, #100
programmingexamhelp.com
5. Registers: X0 = 512, SP=1000, PC=204*
Stack: 1000: 98 ***
Hit enter for next instruction: >
Instruction executed: SUBI SP, SP, #8
Registers: SP=992, PC=208
Stack: 1000: 98
992: **
Hit enter for next instruction:>
Instruction executed: STUR X0, [SP, #0]
Registers: X0 = 512, SP=992, PC=212
programmingexamhelp.com
6. Stack: 1000: 4A
992: 512
Hit enter for next instruction: >
Solution:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MEMORY_SIZE 1024 /* by default memory has size 1024
positions */
#define STACK_SIZE 256 /* size of stack */
#define FIELD_LEN 10 /* maximum length for an instruction field
string */
#define MAX_LINE_LEN 100 /* maximum length in a line */
programmingexamhelp.com
7. /* definition of the register numbers */
enum {
X0 = 0, X1, X2, X3, X4, X5, X6, X7, X8, X9,
X10, X11, X12, X13, X14, X15, X16, X17, X18, X19,
X20, X21, X22, X23, X24, X25, X26, X27, X28, X29,
X30, X31, SP = 28, FP, LR, XZR
};
/**
* Returns the last character in the string
*/
char lastchar(char *str)
{
return (str[strlen(str) - 1]);
}
/**
* Returns 1 if the given character represents a decimal digit, 0
otherwise
*/
int is_digit(char c)
{
programmingexamhelp.com
8. return (c >= '0' && c <='9');
}
/**
* Returns 1 if the given character represents a whitespace char, 0
otherwise
*/
int is_space(char c)
{
return (c == ' ' || c == 'r' || c == 'n' || c == 't'
|| c == 'v' || c == 'f');
}
/**
* Copies the string str2 to str1 removing the first char if fst=1 and
* removing the last char is lst = 1
*/
void copytrim(char *str1, char *str2, int fst, int lst)
{
programmingexamhelp.com
9. if (fst == 1)
str2++;
strcpy(str1, str2);
if (lst == 1)
str1[strlen(str1) - 1] = 0;
}
/**
* Check if a string represents a valid int
*/
int valid_int(char *str)
{
int i = 0;
if (str[0] == '-' || str[0] == '+')
i++;
for (; i < strlen(str); i++)
if (!is_digit(str[i])) /* if not a digit,
is not a number */
return 0;
return (1);
}
programmingexamhelp.com
10. /**
* Split the instruction line by spaces, save the instruction in memory
*/
int save_instruction(char *inst,char mem[MEMORY_SIZE][FIELD_LEN], int nline)
{
char *ptr;
int nparts;
int address;
ptr = strtok(inst, " "); /* split string using spaces */
if (ptr == NULL) /* if can't split */
{
fprintf(stderr, "Error: line %d: invalid instruction formatn",
nline + 1);
return (-1); /* return error */
}
/* try to get the address */
if (sscanf(ptr, "%d", &address) != 1 || address <0 ||
address >= MEMORY_SIZE || (address & 3)) /* if error or
invalid address */
{
programmingexamhelp.com
11. fprintf(stderr, "Error: line %d: invalid addressn", nline + 1);
return (-1); /* return error */
}
ptr = strtok(NULL, " "); /* split next part using spaces */
nparts = 0; /* no parts initially */
while (ptr != NULL)
{
if (nparts >= 4) /* if too many parts */
{
fprintf(stderr, "Error: line %d: invalid instruction
formatn", nline + 1);
return (-1);
}
if (strlen(ptr) > FIELD_LEN) /* if field is too long */
{
fprintf(stderr, "Error: line %d: instruction field %d is too longn", nline +
1, nparts + 1);
return (-1);
}
programmingexamhelp.com
12. strcpy(mem[address + nparts], ptr); /* save field in memory */
nparts++; /* we have one more part */
ptr = strtok(NULL, " "); /* split next part of string using
spaces */
}
if (nparts == 0)
{
fprintf(stderr, "Error: line %d: invalid instruction formatn",
nline + 1);
return (-1);
}
if (address < 200) /*if data address*/
{
/* check for valid number */
if (!valid_int(mem[address]))
{
fprintf(stderr, "Error: line %d: invalid datan", nline + 1);
return (-1);
}
}
programmingexamhelp.com
13. return (0);
}
/**
* Load program code from a file and saves it in memory in the addresses
given
* as the first field in the line
*/
void load_program(char *filename, char mem[MEMORY_SIZE][FIELD_LEN])
{
FILE *f;
char buffer[MAX_LINE_LEN];
int nline;
f = fopen(filename, "rt"); /* open file for reading */
if (f == NULL) /* error opening */
{
fprintf(stderr, "Error: unable to open file "%s"n", filename);
exit(EXIT_FAILURE);
programmingexamhelp.com
14. }
printf("Loading program from "%s"n", filename);
/* read all lines in the file */
nline = 0; /* start at line 0 */
while (fgets(buffer, MAX_LINE_LEN, f) != NULL)
{
/* remove ending spaces and newline */
while (is_space(lastchar(buffer)))
buffer[strlen(buffer) - 1] = 0;
/* skip empty lines */
if (buffer[0] != 0)
{
/* save instruction in memory */
if (save_instruction(buffer, mem, nline) == -1) /* if error
*/
{
fclose(f); /* close file */
exit(EXIT_FAILURE);
}
}
programmingexamhelp.com
15. nline++; /* advance line number */
}
fclose(f); /* close the file */
}
/**
* Shows the contents of all changed registers
*/
void print_registers(int *regs, int *affected, int PC)
{
int i;
int first;
printf("Registers:t");
first = 1;
for (i = 0; i < 31; i++)
{
if (affected[i])
{
if (!first)
programmingexamhelp.com
16. printf(", ");
switch (i)
{
case SP:
printf("SP");
break;
case FP:
printf("FP");
break;
case LR:
printf("LR");
break;
default:
printf("X%d", i);
}
printf("=%d",regs[i]);
first = 0;
}
}
if (!first)
printf(", ");
printf("PC=%dn", PC);
programmingexamhelp.com
17. }
/**
* Prints the stack contents
*/
void print_stack(int sp, char memory[MEMORY_SIZE][FIELD_LEN],
int memused[MEMORY_SIZE])
{
int addr;
int first;
printf("Stack:t");
first = 1;
for (addr = MEMORY_SIZE; addr >= sp; addr-= 8)
{
if (!first)
printf(" t");
printf("%6d: ", addr);
if (memused[addr])
printf("%d", atoi(memory[addr]));
printf("n");
first = 0;
}
programmingexamhelp.com
18. if (first)
printf("n");
}
/**
* Prints the memory
*/
void print_memory(char memory[MEMORY_SIZE][FIELD_LEN], int
memused[MEMORY_SIZE])
{
int addr;
int first;
printf("Memory:t");
first = 1;
for (addr = 0; addr < MEMORY_SIZE - STACK_SIZE; addr += 4)
{
if (memused[addr])
{
programmingexamhelp.com
19. if (!first)
printf(" t");
printf("%6d: ", addr);
printf("%d", atoi(memory[addr]));
printf("n");
first = 0;
}
}
if (first)
printf("n");
}
/**
* Gets the register number from the string if its a valid register Xn
* If not valid returns -1
*/
int get_register(char *reg)
{
int nreg;
programmingexamhelp.com
20. if (!strcmp(reg, "SP"))
nreg = SP;
else if (!strcmp(reg, "FP"))
nreg = FP;
else if (!strcmp(reg, "LR"))
nreg = LR;
else if (!strcmp(reg, "XZR"))
nreg = XZR;
else if (sscanf(reg, "X%d", &nreg) != 1)
return (-1);
if (nreg < 0 || nreg > 31)
return (-1);
return (nreg);
}
/**
* Simulates the program in memory starting at address 200
*
*/
void simulate_program(char memory[MEMORY_SIZE][FIELD_LEN])
{
programmingexamhelp.com
21. int PC;
int regs[32]; /* registers */
int affected[32]; /* registers affected */
int flagZ;
int memused[MEMORY_SIZE];
char *opcode, *op1, *op2, *op3;
char t1[FIELD_LEN];
char t2[FIELD_LEN];
char t3[FIELD_LEN];
int i;
int r1, r2, r3, r;
int halt;
PC = 200; /* start simulating at address 200 */
/* initialize registers */
for (i = 0; i < 32; i++)
{
regs[i] = 0;
affected[i] = 0;
}
programmingexamhelp.com
22. regs[SP] = MEMORY_SIZE; /* stack top at end of memory */
/* initialize memory used */
for (i = 0; i < MEMORY_SIZE; i++)
{
memused[i] = 0;
}
flagZ = 0; /* initialize flags */
printf("Starting simulation...n");
halt = 0;
while (!halt) /* repeat until halt is found */
{
opcode = memory[PC]; /* fetch instruction */
op1 = memory[PC + 1]; /* fetch operands */
op2 = memory[PC + 2];
op3 = memory[PC + 3];
PC+=4; /* advance to next instruction */
programmingexamhelp.com
23. /* clear affected registers */
for (i = 0; i < 31; i++)
affected[i] = 0;
if (!strcmp(opcode, "ADD") || !strcmp(opcode, "ADDS"))
{
if (lastchar(op1) != ',' || lastchar(op2) != ',')
{
printf("n<< Invalid instruction operand at address %d >>n", PC -
4);
halt = -1; /* halt simulation */
}
else
{
copytrim(t1, op1, 0, 1);
copytrim(t2, op2, 0, 1);
r1 = get_register(t1);
r2 = get_register(t2);
r3 = get_register(op3);
if (r1 == -1 || r2 == -1 || r3 == -1)
{
programmingexamhelp.com
24. printf("n<< Invalid instruction operand at address
%d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
r = regs[r2] + regs[r3];
/* if S instruction, update flag */
if (lastchar(opcode) == 'S')
flagZ = (r == 0);
if (r1 != XZR)
{
regs[r1] = r;
}
affected[r1] = 1;
affected[r2] = 1;
affected[r3] = 1;
}
}
}
else if (!strcmp(opcode, "ADDI") ||
!strcmp(opcode, "ADDIS"))
{
programmingexamhelp.com
25. if (lastchar(op1) != ',' || lastchar(op2) != ',' || op3[0] != '#')
{
printf("n<< Invalid instruction operand at address
%d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
copytrim(t1, op1, 0, 1);
copytrim(t2, op2, 0, 1);
copytrim(t3, op3, 1, 0);
r1 = get_register(t1);
r2 = get_register(t2);
if (r1 == -1 || r2 == -1 || !valid_int(t3))
{
printf("n<< Invalid instruction operand at address
%d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
programmingexamhelp.com
26. r3 = atoi(t3);
r = regs[r2] + r3;
/* if S instruction, update flag */
if (lastchar(opcode) == 'S')
flagZ = (r == 0);
if (r1 != XZR)
regs[r1] = r;
affected[r1] = 1;
affected[r2] = 1;
}
}
}
else if (!strcmp(opcode, "SUBI") || !strcmp(opcode, "SUBIS"))
{
if (lastchar(op1) != ',' || lastchar(op2) != ',' || op3[0] !=
'#')
{
printf("n<< Invalid instruction operand at address %d
>>n", PC - 4);
halt = -1; /* halt simulation */
programmingexamhelp.com
27. }
else
{
copytrim(t1, op1, 0, 1);
copytrim(t2, op2, 0, 1);
copytrim(t3, op3, 1, 0);
r1 = get_register(t1);
r2 = get_register(t2);
if (r1 == -1 || r2 == -1 || !valid_int(t3))
{
printf("n<< Invalid instruction operand at address
%d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
r3 = atoi(t3);
r = regs[r2] - r3;
/* if S instruction, update flag */
if (lastchar(opcode) == 'S')
flagZ = (r == 0);
programmingexamhelp.com
29. if (r1 == -1 || r2 == -1 || !valid_int(t3))
{
printf("n<< Invalid instruction operand at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
r3 = atoi(t3);
if (r2 == SP && (regs[r2] + r3 < MEMORY_SIZE - STACK_SIZE))
{
printf("n<< Stack overflow found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else if (r2 == SP && ((regs[r2] + r3) & 7) != 0)
{
printf("n<< Misaligned stack access found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else if (regs[r2] + r3 < 0 || regs[r2] + r3 >= MEMORY_SIZE
programmingexamhelp.com
30. || ((regs[r2] + r3) & 3) != 0 /* if not aligned */
|| !valid_int(memory[regs[r2] + r3]))
{
printf("n<< Invalid memory access found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
memused[regs[r2] + r3] = 1;
if (r1 != XZR)
regs[r1] = atoi(memory[regs[r2] + r3]);
affected[r1] = 1;
affected[r2] = 1;
}
}
}
}
else if (!strcmp(opcode, "STUR"))
{
if (lastchar(op1) != ',' || lastchar(op2) != ',' || op2[0] != '['
|| op3[0] != '#' || lastchar(op3) != ']')
{
printf("n<< Invalid instruction operand at address %d >>n", PC - 4);
programmingexamhelp.com
31. halt = -1; /* halt simulation */
}
else
{
copytrim(t1, op1, 0, 1);
copytrim(t2, op2, 1, 1);
copytrim(t3, op3, 1, 1);
r1 = get_register(t1);
r2 = get_register(t2);
if (r1 == -1 || r2 == -1 || !valid_int(t3))
{
printf("n<< Invalid instruction operand at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
r3 = atoi(t3);
if (r2 == SP && (regs[r2] + r3 < MEMORY_SIZE - STACK_SIZE))
{
printf("n<< Stack overflow found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
programmingexamhelp.com
32. else if (r2 == SP && ((regs[r2] + r3) & 7) != 0)
{
printf("n<< Misaligned stack access found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else if (regs[r2] + r3 < 0 || regs[r2] + r3 >= MEMORY_SIZE
|| ((regs[r2] + r3) & 3) != 0 /* if not aligned */
|| !valid_int(memory[regs[r2] + r3]))
{
printf("n<< Invalid memory access found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
memused[regs[r2] + r3] = 1;
sprintf(memory[regs[r2] + r3], "%d", regs[r1]);
affected[r1] = 1;
affected[r2] = 1;
}
}
}
}
programmingexamhelp.com
33. else if (!strcmp(opcode, "B"))
{
if (!valid_int(op1))
{
printf("n<< Invalid instruction operand at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
r1 = atoi(op1);
if (r1 < 0 || r1 >= MEMORY_SIZE
|| (r1 & 3) != 0) /* if not aligned */
{
printf("n<< Invalid memory access found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
PC = r1;
}
}
}
programmingexamhelp.com
34. else if (!strcmp(opcode, "BL"))
{
if (!valid_int(op1))
{
printf("n<< Invalid instruction operand at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
r1 = atoi(op1);
if (r1 < 0 || r1 >= MEMORY_SIZE
|| (r1 & 3) != 0) /* if not aligned */
{
printf("n<< Invalid memory access found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
regs[LR] = PC;
PC = r1;
affected[LR] = 1;
}
programmingexamhelp.com
35. }
}
else if (!strcmp(opcode, "BR"))
{
r1 = get_register(op1);
if (r1 == -1)
{
printf("n<< Invalid instruction operand at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
if (regs[r1] < 0 || regs[r1] >= MEMORY_SIZE
|| (regs[r1] & 3) != 0) /* if not aligned */
{
printf("n<< Invalid memory access found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
programmingexamhelp.com
36. else
{
PC = regs[r1];
affected[r1] = 1;
if (r1 == XZR)
halt = 1; /* BR XZR halts the program */
}
}
}
else if (!strcmp(opcode, "B.EQ"))
{
if (!valid_int(op1))
{
printf("n<< Invalid instruction operand at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
r1 = atoi(op1);
if (r1 < 0 || r1 >= MEMORY_SIZE
|| (r1 & 3) != 0) /* if not aligned */
{
programmingexamhelp.com
37. printf("n<< Invalid memory access found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
if (flagZ)
PC = r1;
}
}
}
else if (!strcmp(opcode, "B.NE"))
{
if (!valid_int(op1))
{
printf("n<< Invalid instruction operand at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
r1 = atoi(op1);
if (r1 < 0 || r1 >= MEMORY_SIZE
|| (r1 & 3) != 0) /* if not aligned */
programmingexamhelp.com
38. {
printf("n<< Invalid memory access found at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
else
{
if (!flagZ)
PC = r1;
}
}
}
else /*if invalid opcode */
{
printf("n<< Invalid instruction at address %d >>n", PC - 4);
halt = -1; /* halt simulation */
}
if (halt != -1)
{
printf("nInstruction executed:t%s %s %s %sn",opcode, op1,
op2, op3);
programmingexamhelp.com
39. print_registers(regs, affected, PC);
print_stack(regs[SP], memory, memused);
print_memory(memory, memused);
printf("nHit enter for next instruction: >");
fflush(stdout);
getchar();
}
}
printf("nEnd of simulationn");
}
int main(int argc, char **argv)
{
int i;
char memory[MEMORY_SIZE][FIELD_LEN]; /* memory array */
/* by default use code.txt as the input file */
char *filename = "code.txt";
if (argc >= 2) /* if an input file was given */
filename = argv[1]; /* use it as the input filename */
programmingexamhelp.com
40. /* clear memory */
for (i = 0; i < MEMORY_SIZE; i++)
strcpy(memory[i], "0");
/* load program from file */
load_program(filename, memory);
/* simulate the program in memory */
simulate_program(memory);
return (EXIT_SUCCESS);
}
programmingexamhelp.com