Slide #1.

SE3910 Week 3, Class 2  Circuits Exercises  Networking in Linux with C  Code Examples  Threading SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1
More slides like this


Slide #2.

Ex: What is the resistance of this resistor? 2
More slides like this


Slide #3.

Ex: GPIO safety Considering the resistor on the previous slide, is it large enough to not damage a GPIO pin configured as output, if the resistor ties the output to 3.3V?  Sourcing limit: 4mA  Sinking limit: 8mA  Voltage: 3.3 V SE-2811 Dr.Yoder 3
More slides like this


Slide #4.

I was asked this question in an interview today…. "When we create a thread with pthread_create() (POSIX Threads), the thread starts on its own. Why do we need to explicitly call start() in Java. What is the reason that Java doesnt start the thread when we create an instance of it." I was blank and interviewer was short of time and eventually he couldnt explain the reason to me. http://stackoverflow.com/questions/5269535/jav4 SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling
More slides like this


Slide #5.

Threading Java java.lang.Thread No external jar needed Thread t = new Thread(r) t.start(); interface Runnable { void run(); } t.join(); Object o; synchronized(o) { … } … /* Garbage coll. */ Pthreads #include link with -pthread pthread_create(t,r,sr,a) Parameter: void* (*sr) (void *) pthread_join(*t, &p) pthread_mutex_init(m,null) pthread_mutex_lock(…) … pthread_mutex_unlock(…) pthread_mutex_destroy(…) 5
More slides like this


Slide #6.

Threading – pthreads Java Object o; o.notify(); Pthreads phread_cond_t c = PTHREAD_COND_INITIALIZER; pthread_cond_broadcast(c); o.wait(); pthread_cond_wait(c,m); o.notify(); phtread_cond_signal(c); o.notifyAll(); phtread_cond_broadcast(c); • See Java coding example NotifyWaitExample • Caveat: “POSIX threads can wait at condition variables of a greater generality than available in Java, but the SE-3910 - Dr. Josiah corresponding queues may beYoder leaky.” Slide style: Dr. Hornick 6 Much Material: Dr. Schilling
More slides like this


Slide #7.

From Taylor’s We can declare a function pointer by: uint8_t (*min)(uint8_t, uint8_t); We can assign a function pointer to point to an actual function by: uint8_t minimum(uint8_t num1, uint8_t num2) { return num1 < num2 ? num1 : num2; } min = &minimum; We can use it to call minimum using either of the following ways: uint8_t answer = min(3, 8); uint8_t answer = (*min)(3, 8); SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 7
More slides like this


Slide #8.

Threading Java Object o; o.notify(); o.wait(); o.notify(); pthreads phread_cond_t c = PTHREAD_COND_INITIALIZER; pthread_cond_broadcast(c); pthread_cond_wait(c,m); phtread_cond_broadcast(c); • Caveat: See http:// wimhesselink.nl/pub/whh241b.pdf SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 8
More slides like this


Slide #9.

Possibly Fun  Very  simple C++ wrapper for pthreads http://www.cs.utexas.edu/users/lavender/courses /cs345/lectures/CS345-Lecture-09.pdf  notify/wait – example comparison with Java and pthreads  http://wimhesselink.nl/pub/whh241b.pdf  Compares create for Java, pthreads, and Win32 threads  http://cs.millersville.edu/~csweb/lib/userfiles/9Thr eadsII.pdf SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 9
More slides like this


Slide #10.

Certainly fun (Dr. Taylor’s Reviews)  http://msoe.us/taylor/tutorial/ce2810/functionp ointers  Function Pointers  http://msoe.us/taylor/tutorial/ce2810/csimilar  C/C++/Java  http://msoe.us/taylor/tutorial/ce2810/ooc  Object-Oriented C SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 10
More slides like this


Slide #11.

Other references  http://granite.sru.edu/~whit/cpsc464/Notes/fig s/02-14.jpg  Simple pthread chart  From http://granite.sru.edu/~whit/cpsc464/Notes/ch2.html  https://pic.dhe.ibm.com/infocenter/iseries/ v7r1m0/index.jsp?topic=%2Fapis%2Fusers_75.h tm  IBM example of using pthread_cond_init SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 11
More slides like this


Slide #12.

Standards  http://pubs.opengroup.org/onlinepubs/790879 9/xsh/pthread.h.html  pthead.h  http://pubs.opengroup.org/onlinepubs/790879 9/xsh/systypes.h.html  systypes.h – for xxxx_t SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 12
More slides like this


Slide #13.

Real-time and Embedded (Review)  Real-Time  responding as rapidly as required by the user or the process being controlled. - Random House Dictionary (Abbrev.)  Embedded System  A combination of hardware & software to perform a specific function -Dr. Schilling’s slides  Often real-time SE-1021 Dr. Josiah Yoder Slide style: Dr. Hornick 13
More slides like this


Slide #14.

PC Contains separate • Microprocessor(s) • Memory • Peripheral (I/O) device HW • serial port • • • • • • SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling parallel port USB port Bluetooth port IR port AGP port WiFi port,… 14
More slides like this


Slide #15.

Beaglebone SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 15
More slides like this


Slide #16.

 Our Favorites http://letsmakerobots.com/node/37063?page=3 16
More slides like this


Slide #17.

Finding GPIO Port ������ ��� ������= ��������������������∗32+������� (Useful on the basic proto cape) SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 17
More slides like this


Slide #18.

The breadboard cape SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 18
More slides like this


Slide #19.

The breadboard cape SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling 19
More slides like this


Slide #20.

The breadboard cape ITM QTY REF PART 1 1 PCB 2 2 P1, P2 2x23 HDR FE 3 1 P3 8 PIN HDR FE 4 2 S1, S2 BUTTONS 5 2 D1, D2 LEDS 6 2 R1, R2 RESISTOR 7 1 BR1 BREADBOARD 8 1 JMPR WIRE KIT DESCRIPTION 2-LAYER 3.4" x 2.15" DUAL - STRAIGHT SOCKET STRIP .025" SQ. PINS CONN HEADER FEMALE 8 POS 0.1" GOLD SWITCH TACT SPST-NO .05A 24V LED GREEN 3MM 568NM 20mA 2.12V RES 470 OHM 1/4W 5% CF MINI WHT ADHSV SLDRLSS BRDBRD 170 TIE PT 1.8" x 1.37" 10 x 14 LNGTH .1" .2" .3" .4" .5" .6" .7" .8" .9" 1" 2" 3" 4" 5" SE-3910 - Dr. Josiah Yoder Slide style: Dr. Hornick Much Material: Dr. Schilling DISTR PART # MLE DK DK DK DK PLU SQR SSHQ-123-D-08-F-LF PPPC081LFBN-RC B3F-1000 WP7104SGC CFM14JT470R 1490 20
More slides like this


Slide #21.

References EB: Derek Malloy, Exploring Beaglebone, Wiley, 2015 SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick 21
More slides like this