tamás péter (d. 424) mechatronika, optika és gépészeti ... informatikai tÁrgyak... · web...
TRANSCRIPT
II. Programming Technologies
II.1 The machine code programCode of algorithm steps + memory addresses:
MOV AX,1234h ;0B8h 34h 12h - number (1234h) to AX registerMUL WORD PTR [5678h] ;0F7h 26h 78h 56h - multiply AX with the data of the given address (extra segment)MOV [5678h],AX ;0A3h 78h 56h - write back the result in AX to the address
II.2 Program making programsSource code program >> Compiler/Interpreter >> Executable program
Generation of Languages1GL: machine code2GL: assembly (mnemonics)
3GL: high-level procedural:• FORTRAN, PASCAL, C
4GL: problem oriented:–Functional: LISP (LISt Processing),–Logical: PROLOG (PROgraming LOGics),–Database management: SQL,
–Object-oriented: C++, JAVA. C#, –Component based development languages.
5GL: natural languages???
Timeline of programming languages
Some interesting dates:• 1st: Eniac coding system (von Neumann and others - 1943)
• BASIC (Kemeny/Kurtz- 1964), Altair BASIC (Bill Gates, Paul Allen – 1975), Commodore BASIC (1975), IBM BASIC (made by Microsoft – 1981)
• Pascal (Niklaus Wirth /Kathleen Jensen – 1970)
• C (Dennis Ritchie - 1972), C++ (Bjarne Stroustrup - 1983), C# (Anders Hejlsberg – 2000, Java (James Gosling –Sun Microsystem – 1995)
II.3. Data and Programs
[const| readonly] type_name variable_name [,…][= starting_value]
Integers:byte / sbyte 0..255 / -128..127 1 byte ushort/ short 0..65 535 / -32 768..32 767 2 byteuint, int 0.. 4 294 967 295 / -2 147 483 648..2 147 483 648 .. 4 byte
Logical typeBool false..true 1 byte
Floating point (real number) typeFloat -3.4×1038.. 3.4×1038 4 byteDouble ±5.0×10−324.. ±1.7×10308 1.3, 2.1e6, 3.4F, 4.2L 8 byteDecimal (-7.9 x 1028.. 7.9 x 1028) / (100..28) 28, 29 digits
Letters:Char ’A’, ‘\n’, ’\t’(!!!) 2 byteString ”Apple” n*2byte
Enumerated lists:Enum enum number {one, two, three} // 0,1,2
enum thislist {a=6,b=11} // 0..15number.two
II.3.2 Basic algorithm elements
II.3.2.1 Concatenation
int i = 3; int j = 4; int k = i + j;
II.3.2.2 Alternation (selection)
if (i > j) { k = i - j; } else { k = j - i;}
II.3.2.3 Iteration (cycling)
i = 0;k = 0;while (i < 10) { k += i++;}
II.4. Subprograms, Functions
type_name name ([parameters]) { // function body
p
f
it
f/t
t/f
p
fv
call fv
[local definitions, declarations][statemens][return [value]; // if exists] }
Usage modes:
function_name([param1, param2,…]);
i = name([param1, param2,…]);
int main () {}
II.5 Object, class (to be discussed in details in seminars)
ObjectData
Program
II.6. Windows is an event-driven program
}}
}Console.Beep();
{e)EventArgssender, objectbutton1_Click(private void
}InitializeComponent();
{Form1()public{Form1 : Formpublic partial class
{WindowsFormsApplication1namespace Case
Message Loop
DefWindowProc
Windows
Message queue
CallBack
WinMain
Maximum CPU utilization ? Multiprogramming.
• Several processes are kept in memory at one time.
• Any process can take over the CPU.
• Process Scheduler is the component of the OS.
• Scheduling of the CPU is fundamental to OS design.
Scheduling Objectives:
• Share time fairly among processes• Prevent starvation of a process• Use the processor efficiently• Have low overhead• Prioritise processes when necessary
Windows NT-based operating systems (including Windows 8.x and 10.x) use a multilevel feedback queue. 32 priority levels are predefined. General rules:
◦ Give preference to short jobs.
◦ Give preference to I/O bound processes.
◦ Quickly establish the nature of a process and schedule the process accordingly.
All processes receive a priority boost after a wait event, but processes that have experienced a keyboard I/O wait get a larger boost than those that have experienced a disk I/O wait.
II.7. Windows pre-emptive multiprogramming
System and application waiting queues
Timeslice distribution with variable priorities
42
distribTimeslice
Primary scheduler
pr=12pr=20pr=16
pr=20
pr=4
thread5
thread4thread
3
thread2
thread1
MS-DOS VMMS-DOSS VMSystem VM
16 Bit appsapps
32 Bit apps
Messages
primarywaiting queue
16 bit appwaiting queue
32 bit threadwaiting
queue
bit thread
32waiting queue
bit thread
32
System Applications
Waiting line
Messages
DevicesMouseKeyboardDisks Printer
II.8. Rapid Application Development Environment Component based development:
}}
}BackColor = System.Drawing.Color.Red;button1.Text = "alma";
{private void button1_Click(object sender, EventArgs e)
}InitializeComponent();
{public Form1()
{public partial class Form1 : Form
{namespace WindowsFormsApplication1
using System.Windows.Forms;using System.Text;using System.Linq;using System.Drawing;using System.Data;using System.ComponentModel;using System.Collections.Generic;using System;
II.9. Microsoft.Net
Aim: Safe development
trudctureSypeTommonCCTS
nfrastructureIanguageLommonC
CLI Network solutions•
independency-Platform•
compilerime Tn Iust J
JIT
anguageLntermediateI
ommonCCILetc.Managed C++ J#JScriptVB.NetC#
New, CLR functions (garbage collection)
servicesWeb
)anguageLarkup Mtensible Xe-(XML Data with multilevel type checking
Basic Classes
Operating System
machineCode runs on virtual amchines virtuális
(untimeRanguageLommonC–CLR
Web/Windows user layer
Existing functions (file open)