System Software 3
System Software 3
CAP318
HOME WORK – III
DECLARATION
It is declared by me that this assignment is purely my effort and I had done my
assignment of my own. I accept that I had taken the help of internet and
books of modern programming tools and technique but I had used my own
language while answering the questions of homework 1. I had tried my best
to make my assignment unique from other student.
DECLARED BY
Surendra
Part A
Q 1.With figure illustrate how loading and calling of a subroutine can be done
using dynamic linking.
Ans.
Dynamic linking involves loading the subroutines of a library into an
application program at runtime, rather than linking them in at compile time;
the subroutines remain as separate files on disk. Only a minimum amount of
work is done at compile time by the linker; it only records what library
routines the program needs and the index names or numbers of the routines
in the library.
The majority of the work of linking is done at the time the application is
loaded (lead-time) or during execution (runtime). The necessary linking
code, called a loader, is actually part of the underlying operating system. At
the appropriate time the loader finds the relevant libraries on disk and adds
the relevant data from the libraries to the process's memory space.
”loading
and calling of a subroutine using dynamic linking”
l
Load-and-call
“A subroutine is loaded and linked to the rest of the program when it is
first called usually called dynamic linking, dynamic loading or load on
call.”
Dynamically loaded must be called via an operating system service request.
Load-and-call service
1. OS examines its internal tables to determine whether or not the routine
is already loaded.
2. Routine is loaded from library
3. Control is passed from OS to the called subroutine
4. Subroutine is finished
5. Calling to a subroutine which is already in memory
6. Binding of the name to an actual address is delayed from load time until
execution time
2. Int * p;
p = array;
After that, p and array would be equivalent and would have the same properties. The
only difference is that we could change the value of pointer p by another one,
whereas array will always point to the first of the 25 elements of type int with
which it was defined. Therefore, unlike p, which is an ordinary pointer, array is an
array, and an array can be considered a constant pointer. Therefore, the following
allocation would not be valid:
array = p;
Because array is an array, so it operates as a constant pointer, and we cannot
assign values to constants.
Due to the characteristics of variables, all expressions that include pointers in the
following example are perfectly valid:
int main ()
{
int array[6];
int * p;
p = array; *p = 20;
p++; *p = 21;
p = &array [2]; *p = 22;
p = &array +[3]; *p =23;
p = array; *(p+4) = 24;
p=&array[5];*p=25;
For (int k=0; k<6; k++)
Cout<<”the array elements are : ”;
Cout << array[k] << ", ";
Return 0;
}
Data structures are used in almost every program or software system. Specific
data structures are essential ingredients of many efficient algorithms, and make
possible the management of huge amounts of data.
Types of Data Structure:
• Linear/Branching — There is only one direction to go, yet different paths can
be taken. This structural form is hierarchical and organized.
Examples are Arrays, Linked list, Stack, Queue.
• Nonlinear/Matrix — There are many directions to go. One can enter at any
point and move to any other point at any time. All directions and points can be
equally reached.
Examples are Trees, B-Trees, and Graph.
• Random/Schizo — all directions are equal and unequal at the same time. This
structure is more theoretical, and represents neurological and psychological
depths. A computer or algorithms can never truly repr.
• Abstract data type- A data structure that is defined indirectly by the
operations that may be performed on it, and the mathematical properties of
those operations
Part B
Q1. Why macro is said to be recursive?
ANS.
MAINED allows a macro to invoke itself. Macros that invoke themselves are called
recursive macros. A recursive macro executes until some command in its definition
command sequence fails. For example, the search and skip commands fail when they
cannot find their targets. On some operating systems, it is also possible to terminate
recursive macro execution with the <abort> key.
It is the "internal" version of the macro transition that is called recursively. There is no
respawning included in the definition of this "internal" version other than that caused
by recursive calls.
If a macro does call itself that call must be within a conditional block that eventually is
skipped over. Macros of this sort are called recursive macros,
The macro declaration is
Macro macro_name //macro declaration
Statements
-------------------
Mend //end of macro
ANS.
MACRO
Macro programs are also referred to as macro recorder, macro software, macro automation
program, keyboard macro, etc.
Macro programs are a great productivity tool. They allow you to perform an otherwise long,
boring or complex task just by a single click.
I classify macros programs into 2 types.
1. Macro recorder: These provide record macro and re-play macro capabilities. You do not
need to know programming.
2. Macro Automation software: These offer a small macro language of its own in addition
to providing macro recording and re-play capabilities. Using macro automation software
you can record a macro or automation script and then use an editor to edit the script, add
new actions to a macro script or even write a macro from scratch using simple macro
language.
Program:
An organized list of instructions that, when executed, causes the computer to behave
in a predetermined manner. Without programs, computers are useless.
A program is like a recipe. It contains a list of ingredients (called variables) and a list
of directions (called statements) that tell the computer what to do with the variables.
The variables can represent numeric data, text, or graphical images.
• Int max (int c, int a, int b) {vs. #define max(c, a, b) (c = ((a>b)? a: b))
c = (a>b)? Return a: return b;
}
• Int main () {
Int x=3, y=5, z=0;
Max (z, x++, y++);
Printf (“max of x=%d and y=%d is %d\n”, x, y, z);
}