ECE 4180 - Test 2

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

n Windows, a device driver must be written in __C++__ and setup as a Visual Studio _*.DLL_ project

%) In a C++ Windows GUI application, exactly what is the significance of PostQuitMessage(); and what other common API is always associated with it?

BSP

(acronym) term for the collection of low level drivers, I/O device drives, and bootstrap loader needed to initially bring up an OS on a new target board With a new target board that runs an OS, a _____________ (acronym) is typically provided which includes the OS configuration for the board along with all of the required device drivers.

bootstrap loader

))))))))))) is the program responsible for initially loading the OS binary code when the computer first powers up. (any OS in general, not specific to the CE OS)

extern

. The C/C++ standard keyword ____________ makes a function available outside of a source code module for use by other separately compiled modules

Createthread(NULL,0,nethread,(LPVOID)nParameter,0,&dwThread1ID);

1. (5%) Write a Windows OS API that would be used to create a new thread running a C++ function called "newthread()"

C/C++ *.DLL external file system APIs

1. A windows stream interface driver must be written in ________________ and must be setup as a _______________ Visual Studio project with the required driver entry points declared as ________. Once a stream interface driver is available, application programmers can use standard simple OS ____________ to communicate with the I/O hardware

/dev/ttyACM0 COMx file system

1. Communication via USB is possible with mbed in Linux using the device name______________ and in Windows using the device name _______________ (only common prefix needed) using the standard OS ________________ APIs.

Convert code to an OS Stream Interface Driver in a DLL project and add new driver to OS

1. How could the code in the previous problem be modified so that other users could just use standard OS file systems APIs to communicate with the new device? (include the common term for the easiest approach) (last q: adding functionality to a read write driver)

yield

1. In the mbed RTOS, ________works in threads just about the same as the Windows C++ Sleep(0) API.

entercriticalsection leavecriticalsection ___________mutex.lock_________________ and ____________mutex.unlock_____________

1. List the two Windows OS C/C++ APIs that are used for a fast (mutex-style) lock and unlock on critical code sections in threads. (Just API names - no arguments needed here in the answer): In the mbed RTOS, list the two APIs below that would do roughly the same operations: ___________mutex.lock_________________ and ____________mutex.unlock_____________

cloud server local

1. Most IoT devices and the applications that control/monitor them remotely communicate on the Internet through a ________________which has a registered domain name, user account, and additional processing resources, since many IoT device network connections only have _____________IP address

400k 40M 13 micro

1. The smallest CE kernel can be around ________-bytes and the largest kernel with all features including networking, full debugging support, and .NET Compact Framework runs around _______________bytes. For real-time systems, the worst case ISR latency runs around _________seconds on a typical ARM processor. (approximate numbers are acceptable here)

close closehandle write writefile

1. To close a file in C++, the ____________native OS API is used in Linux and ______________in Windows. The file is written using ______________in Linux and _______________in Windows.(API names only- no arguments needed)

n=sprintf(buffer,"Hello mbed"); WriteFile(hSerial,buffer,n,&cbytes_out,NULL);

1. Write two C++ Win32 API calls (i.e., not complete programs) to do the following items. Use the handle hSerial and buffer for a string of characters, and assume they are already declared elsewhere. API Call 1: Open the USB virtual com port to an mbed at COM54: (at default baud rate) hSerial = CreateFile(_T("\\\\.\\COM54:"), GENERIC_WRITE, 0, NULL, OPEN_EXISTING,0,NULL); API Call 2: Write the string "Hello mbed" to the mbed using the USB Virtual Com Port

P4 or Itanium Processors

4180t2.pdf #4

BSP

A Board support package (BSP) includes the software needed to support a board and develop different OS versions for it. It typically includes: A Bootloader The OEM Adaptation Layer (OAL) software All device drivers needed for the board

Callback

A Windows C++ GUI program's ___________ function decodes and executes the code needed for each message sent by the OS to the program.

stream interface registry entry

A _______________ driver is the easiest way to add a new driver to a desktop OS. In Windows, a new __________________ must also be added, so that the OS knows a new device and driver is available.

A message dispatch table is an array of pointers to each procedure used in the Windows call back procedure for each message. It is used instead of a long case statement for faster execution time.

A message dispatch table is an array of pointers to each procedure used in the Windows call back procedure for each message. It is used instead of a long case statement for faster execution time.

while((read_port_uchar(0x3E1) & 0x40)!=0) Sleep(0); inchar = read_port_uchar(0x3E0);

A new X86 I/O device is running on a PC with the Windows OS and does not have a driver. Write a short C/C++ code segment using the write_port_uchar() and read_port_uchar() I/O functions to read 1 byte named, inchar, from the I/O device using simple polling for I/O transfers. The device has an I/O data register at 0x3E0 and a status register at 0x3E1. A high value on status register bit 6 indicates the device is output ready. Yield the rest of the OS time slice, whenever the device is not ready

while((read_port_uchar(0x3E9) & 0x40)==0) Sleep(0); mychar = read_port_uchar(0x3E8);

A new X86 I/O device is running on a PC with the Windows OS and does not have a driver. Write a short C/C++ code segment using the write_port_uchar() and read_port_uchar() I/O functions to read 1 byte named, mychar, from the I/O device using simple polling for I/O transfers. The device has an 8-bit I/O data register at 0x3E8 and a status register at 0x3E9. A high value on status register bit 6 indicates the device is output ready. Yield the rest of the OS time slice, whenever the device is not ready.

void print_char(char outchar){ while((read_port_uchar(0x3E3) & 0x10)!=0) Sleep(0); write_port_uchar(0x3E2, outchar); }

A small thermal printer is attached to a PC running Windows to provide receipts. I/O address 0x3E2 is used for 8-bit data transfers, and bit 4 high on the status port at 0x3E3 indicates the printer is ready for another character. Write a short C/C++ function, print_char(outchar), using polling and the write_port_uchar() and read_port_uchar() I/O functions to write an ASCII character named, outchar, to the printer. Yield the rest of the OS time slice whenever the device is not ready.

SerialPort . WriteLine

C# method is used to send data out from a PC's RS232 communication port.

PostQuitMessage generates WM_QUITmessage that passes through GetMessage function in the while loop check condition to return 0 (basically ends the loop)

C/C++ windows GUI callback funciton, postQuitMessage found somewhere... why is it needed

bib

CE subproject's ____ File tells the compiler and the batch build system what files to include in the kernl in the NK.bin file

*.reg

CE subprojects _____ file tells the compiler and the batch build system what entries to add and include in the initial registry in the NK.bin file (at boot time)

Init I/O driver, select pin function for digital output, set pin, clr pin, terminate driver

Describe the function (in a few words) of the I/O library API calls were required setup and flash the LED on the Pi?

wait(0.0001) thread::wait(1) sleep(0.0001) Sleep(1)

For a short 1 ms time delay on mbed bare metal use ____________, in the mbed 2.0 RTOS use ____________, in Linux use __________ and in Windows use __________(arguments must be correct for credit)

Each USB microprocessor contains extra hardware called a Serial Interface Engine (SIE). The SIE performs high speed serial to parallel conversion (using shift registers and buffers) so that the microcontroller only needs to handle parallel data at a much lower data rate.

How can a relatively slow low-cost microprocessor support the high serial data rates needed for a USB interface? Explain any additional hardware needed.

bed device name is /dev/ttyACM0. File APIs used in Linux are open, read, write, and close

How can the Pi communicate with mbed via the USB cable using OS File APIs and what device name and APIs are used on the Pi?

Mode command with value of 1000X00X to the control port

How could you force an 8255 I/O chip to have both ports A and B function as output ports

uses a DMA controller to send out a binary bit pattern to a pin to generate a PWM signal

How does the PIGPIO I/O library provide more PWM output pins with an "almost" PWM hardware solution

C# can call C++ functions setup as external references in a *.DLL project. It is called "Platform Invoke" or just "Pinvoke"

If C# does not support a needed low-level function, what is the common alternative that could still make that function available in a C# program? (Explain and include the common name used for it)

Add a mutex lock to control access to the new C++ class

If an mbed RTOS program has a global variable that is a new C++ class, and not a basic C predefined type, volatile is not enough to make it R/W access safe in multiple threads using the mbed ARM compiler. How could you fix this?

Serialport

In C#, the _____________ method can be used to communicate with the mbed's USB virtual com port.

createthread Sleep(0)

In Windows WIN32 using C++, ________________________starts a new thread and _____________________ yields a thread.

C++ *.DLL

In Windows, a device driver must be written in ___________ and setup as a Visual Studio _____________ project

Polling in while loop consumes too much processor time and power. Use interrupts

In a complex system, what are the limitations of the simple I/O transfer solution in the previous problem and how could it be improved to require less processor time? (last q: adding functionality to a read write driver)

WinMain

In a typical C/C++ MS Windows GUI application, winmain? Winmain is the initial entry point of a Windows GUI application. It sets up, registers, and displays the initial window for the application and always ends in a windows messaging loop. The windows messaging loop handles all of the messages specific to the application's window by translating and dispatching messages. The application's callback function decodes the message and includes the code needed to implement each windows message.

On mbed not PI: Analog Input Analog Output CAN Bus Ethernet (Pi Zero W) On PI not mbed: CSI (camera) HDMI (video) Wi Fi & Bluetooth

List at least three standard I/O interfaces found on the mbed that are not available on the PI and one on the PI, but not on mbed

IEEE 1394 - M L M L USB (1.0) - L M L M

M more L less cost, length, bandwidth, # devices

CIL

Microsoft's acronym for C#'s equivalent to Java Byte Codes

Semaphore 1

On mbed, a ________________ initialized to ______ functions the same way as a mutex synchronization lock.

P4 has a deeper pipeline so mispredicted branches will incur greater stall penalty

P4 not always a lot faster than P3 at the same clock frequency?

Mbed RTOS ___2___ Windows__5___ Linux ___4___ Windows IoT___3___ Bare Metal (no OS)___1___

Rank the likely real-time response times for the following options assuming hardware is about the same for each (1-fastest, 5-slowest).

SetCommMask WaitCommEvent

SetCommMask WaitCommEvent

entercriticalsection leavecriticalsection

The C WIN32 APIs _________________and ____________________can be used to provide a fast mutex lock/unlock in threads

20+or 30+(new P4

The P4 processor contains dynamically scheduled pipelines with up to ________________ stages.

6 1

The mbed has _________ hardware PWM outputs and the Pi Zero W has _________

They only have a local IP address, so a remote device on another subnet cannot initiate network communications

They only have a local IP address, so a remote device on another subnet cannot initiate network communications

The C WIN32 APIs entercriticalsection and leavecriticalsection can be used to provide a fast mutex lock/unlock in threads

Variables or I/O devices with R/W access by multiple threads or processes always require ____________________ for proper operation.

Serialport - added by dropping serial connector tool in GUI - can edit properties to select COM port number and baudrate, if needed

What C# method was able to communicate with the mbed in lab 5 and how was it setup in the tutorial

How can a relatively slow low-cost microprocessor support the high serial data rates needed for a USB interface? Explain any additional hardware needed.

What are the difference and tradeoffs in a hard vs. soft IP core in FPGAs?

CE provides several synchronization objects that enable you to synchronize a thread's actions with those of another thread. These objects include critical sections, mutexes, events, and semaphores.

What different synchronization primitives are available in CE?

Link Pthread RT, and PIGPIO library code and execute using "sudo

What had to be changed in the Pi's Geany C++ IDE GUI's default compile, build and execute options to use PIGPIO to blink the LED in lab 4?

SIE is the Serial Interface Engine. Hardware must be used to support the high clock rates needed for parallel to serial and serial conversion between the USB bus and the USB microcontroller. hip on a PC motherboard connects to the PCI bus and provides the legacy ISA bus signals.

What is a USB SIE and why is it needed? Explain

MMU (virtual memory unit) provides hardware memory protection of memory area for I/O registers in user code

What processor hardware feature forces the use of "sudo" to run PIGPIO and most other programs using an add-on I/O library APIs to use I/O pins on the Pi?

It jumped from the VS form editor tool directly to the C# code for a button click event

What was the lightning bolt icon used for in the lab 5 Visual Studio tutorial?

When messages (i.e. keyboard and mouse events) are sent to the windows application and dispatched by the windows messaging loop, the OS activates the callback function. It has a case statement with the code that handles each message for the application.

When messages (i.e. keyboard and mouse events) are sent to the windows application and dispatched by the windows messaging loop, the OS activates the callback function. It has a case statement with the code that handles each message for the application.

4180t2hs.docx

Where is the code to implement the operations required for each message in a C/C++ Windows GUI application located and how does it work?

The PI uses C style function calls and requires more explicit API calls. The mbed requires fewer since it uses C++ classes with a constructor/destructor and automatic operator overloading for many of the read/write operations.

Which requires more explicit I/O API calls in a user's C++ source code for communication with an I/O device like an LED or sensor, the Pi with Linux or the mbed? Explain exactly why?

The OS sets up the user's MMU virtual memory address space with hardware protection of I/O registers and application code cannot access them directly

Why can't simple C pointers be used to communicate directly with the Pi's I/O registers in a user program like we did in several of the low-level mbed I/O examples?

Visual studios has fast GUI dev with C# through forms editor with simple callback functions but C# runs inside a virtual machine (not in machine code) so its slower

Why is C# faster GUI coding but slower execution time

Most IoT devices get only a local IP address that can only be used on the same subnet, so a cloud server is used for communication and control on the Internet. An account and password also helps with security, but could be done on device if not for the local IP issue

Why would even a very simple IoT device like a light switch need a user account and password on a server to talk to the IoT device instead of direct communication for control over the Internet?

GetTickCount

Windows C++ API ____________ returns the number of milliseconds since OS boot time.

Windows GUI application, what is the significance of WM_DESTROY and what two APIs are normally associated with it

Windows GUI application, what is the significance of WM_DESTROY and what two APIs are normally associated with it

The standard desktop versions of both are likely a bit too slow. Linux is a bit faster than Windows. Interrupts can be disabled for long periods of time in the kernel and threads can be preempted for hundreds of milliseconds (worst case). There are RTOS versions of both, but they also still tend to be a bit slow and have a slower time slice compared to an OS designed to be an RTOS for hard real-time systems. Supporting virtual memory page swapping to disk and automatic garbage collection limits the real-time performance of general performance operating systems.

Would the Linux or Windows OS be an appropriate choice for applications that must have a response time of no more than a few milliseconds? (Justify your answer

hSerial = CreateFile(_T("\\\\.\\COM22"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

Write a Window's C++ OS file system API call that would open the mbed serial port at COM22 for R/W.

gpioWrite (17, PI_OFF);

Write a line of C code below using the PIGPIO library APIs that would turn off GPIO bit 17. Assume the library and pin functions are already initialized.

TCHAR STRING1[] = TEXT("ECE 4894")

Write the code needed to declare and initialize a Unicode string pointer named STRING1 to "ECE 4894"

RPC

____ is a simple standard way to call a function on another computer, pass arguments, and return values using any communication channel that sends and receives ASCII bytes.

platformInvoke

____ is the term used for hte process that C# can use to call a C++ routine (used for calling native/routine?? code from managed code)

southbridge

_______ chip on a PC motherboard connects to the PCI bus and provides the legacy ISA bus signals.

____extern_________

_______ is likely needed for any hard real-time system that needs around a millisecond response time or better. (Type of Operating System)

boot loader

_______ program responsible for initially loading the OS binary code in memory when computer first powers up (any OS, not just CE OS)

stream interface driver

________ typically is the simplest model to write a custom I/O device driver for an OS. It assumes the device produces or consumes streams of bytes at a moderate data rate.

SDK

_________ is used by applications developers so that they can develop standalone code for a new OS (without having to build it or understand the OS build operation). It defines the libraries and APIs available in a specific build of the OS for C/C++/C# applications.

RMA/RMA 60

__________ scheduling in an RTOS ensures that real-time constraints are met by assigning a higher priority to threads with faster real-time response rates as long as not more than around ____________ of the processor time is used

.net framework

___________ os the name of the C# virtual machine The virtual machine for C# (.Net Framework) requires several megabytes What is the main factor that makes even a short C# program require significantly more memory than C/C++?

SoPC FPGA

___________ technology uses a processor with user designed custom logic inside a single large____________ to build a system

device driver

______________ is the name for the lowest level software routine in an Operating system that talks directly to a specific type of I/O device.

dirs

by checking eat project and subproject's _____ file, the windows CE build system automatically finds all of the other directories and files needed to build the OS

USB

connector type you would expect to find the most of, on the back panel of next generation PCs

4180t2l.pdf

how does a windows GUI application's windows messaging loop ever terminate and what API call will eventually make this happen? what is a BSP and why should you look for it carefully when selecting a new target board for a project that requires an OS? more CE code

4180t2o.pdf

how was the low-level x86 I/O code set up in the CEDDK OS C/C++ source code for the write_port_uchar function?

4180t2s.pdf

idk generally good short (long) response answers but idt we'll be asked anything

destination MAC address

in each Ethernet packet identifies which computer gets the data payload

safety critical coding

is the term (must be one used in class & slides) for the more involved process and rules used to develop software that can endanger people or cause catastrophic failures is the term used for the required more extensive time consuming software development and testing process needed in a device that can endanger people or property in the event of a software failure.

recursion, dynamic memory allocation after program start, multiple levels of pointers, Goto statements, no fixed upper bounds on loops.

ist two common language features that are problematic in safety critical coding applications

InitializeCriticalSection EnterCriticalSection leaveCriticalSection

list Windows OS C/C++ APIs used to setup and use fastest (mutex style) lock on critical sections in threads (not processes)

HANDLE (type) createSemaphore waitForSingleObject releaseSemaphore closeHandle

list all of the windows OC C/C++ APIs used for semaphores

HAL OAL (lowest)

lowest level hardware functions (interrupts, timers, chace, mmu, etc) that must be developed as first step in initially bringing up OS on new target board without BS (even lower than standard I/O device drivers)

getTickCount()

simply windows API used to output incrementing integer value that can be used a a time stamp

sources

the ____ file in a winCE OS build subproject contains the include file paths and the libraries used to compile and link the subproject

Electroplating

the chemical process used that connects layers in PCB feedthrough holes after they are drilled out

playsound

the simple ______ windows API can be used to output a *.wave file on the audio output device

??? sleep(0) ?

thread is in a tight do-while loop waiting for I/O status bit on slow device to change. to avoid spending too much time checking the bit and slowing the OS, which Win32 API added?

4180t2k.pdf 4180t2rsol.pdf

what callback function does in C/C++ windows GUI (#3) why widely used desktop OS not best for embedded devices (i.e., fast response time)? CE OS API calls (new threads, definition, semaphore)

4180t2m.pdf

what causes a windows gui application to terminate via the mouse click on the corner red X box and exactly how does it work? describe the sequence of events and all of the functions involved what type of application or devices would require an RTOS and not the typical desktop OS? approximate numerical examples more CE code

VM provided in .NET framework takes up a few MB

why very short standalone C# programs take more memory to execute than a short C++ program

4180t2n.pdf

win CE .NET compact framework OS build catalog item? (runs CLI code in protected environment on top of WinCE)

CreateThread createProcess

windows & CE -> the API _______ is used to start a new thread and ______ is used to start a new process (C/C++)

WaitForSingleObject

windows CE API ____ is used to wait for thread and process synchronization lock and events ________________ Windows API can be used to wait on a semaphore as well as some other synchronization primitives.

waitForSingleObject releaseSemaphore

windows OS C/C++ APIs used to lock and unlock sempahores

Windows messaging while loop must be included at the end of each application's WinMain function. constantly translates and dispatches messages to the window such as the mouse clicking a window button. dispatched messages will cause the OS to eventually activate the applications callback procedure. without a messaging loop, a windows application would not respond to keyboard or mouse events

windows messaging loop, why is it needed, and where is it found?

GetProcAddress

windows, processes explicitly linking to DLL can call ________ API to obtain address of an exported function in DLL at runtime https://docs.microsoft.com/en-us/cpp/build/getprocaddress?view=msvc-160

Windows/Linux not designed to provide real time response for a few milliseconds. intended for 100s of ms... RTOS usually needs less memory -> processor performance and power management

would windows/linux OS be appropriate choice for applications that need fast response time (few ms)


Ensembles d'études connexes

Cybersecurity Analyst (CSA+) - Practice Test

View Set

MKT Research Exam 2 - Mindtap Q's

View Set

French quiz comparative and superlative 2/27/17 (chapter 6)

View Set

mktg 371 chapter 10- buying and disposing

View Set

Properties of Gases and Equations

View Set

Chapter 5 Chemistry Test Balentine

View Set